void main(){
LifeBar();
playerNameScorePos();
// getchar(1,1);
// digit_num(8);
// trunc(1);
}
void LifeBar(){
void P1 = getplayerproperty(0, "entity");
void P2 = getplayerproperty(1, "entity");
void P1LBar = getglobalvar("P1LBar");
void P2LBar = getglobalvar("P2LBar");
void Box = getglobalvar("Box");
void CheckeredLifeBarBox = getglobalvar("CheckeredLifeBarBox");
if(P1){
drawsprite(P1LBar, 8, 0, 1000);
drawsprite(CheckeredLifeBarBox,40,9,285);
// int MP1 = getentityproperty(P1, "mp");
int LP1 = getentityproperty(P1, "health");//Player 1 health bar
int TP1 = getentityproperty(P1, "maxhealth");//Player 1 total health bar
int HP1 = 96*LP1/TP1;//Player 1 main health bar health value * health/maxhealth (e.g. 114*100/100 = 11400/100 = 114)
//Main P1 lifebar
drawbox(40,9,HP1,1,1800,rgbcolor(99,140,0),0); //drawbox(x,y,width,height,color,alpha)
drawbox(40,10,HP1,1,1800,rgbcolor(222,239,0),0);
drawbox(40,11,HP1,2,1800,rgbcolor(255,255,0),0);
drawbox(40,13,HP1,2,1800,rgbcolor(198,214,0),0);
//Main P1 MP
//Zipper bars
//48 bars
if(LP1==1){
NULL();
}
if(LP1>=TP1*0.02){ //1 (e.g. 1/48 = 0.02)
drawsprite(Box,40,12,5000); //First bar;
}
if(LP1>=TP1*0.04){ //2
drawsprite(Box,42,12,5000);
}
if(LP1>=TP1*0.06){ //3
drawsprite(Box,44,12,5000);
}
if(LP1>=TP1*0.08){ //4
drawsprite(Box,46,12,5000);
}
if(LP1>=TP1*0.10){ //5
drawsprite(Box,48,12,5000);
}
if(LP1>=TP1*0.13){ //6
drawsprite(Box,50,12,5000);
}
if(LP1>=TP1*0.15){ //7
drawsprite(Box,52,12,5000);
}
if(LP1>=TP1*0.17){ //8
drawsprite(Box,54,12,5000);
}
if(LP1>=TP1*0.19){ //9
drawsprite(Box,56,12,5000);
}
if(LP1>=TP1*0.21){ //10
drawsprite(Box,58,12,5000);
}
if(LP1>=TP1*0.23){ //11
drawsprite(Box,60,12,5000);
}
if(LP1>=TP1*0.25){ //12
drawsprite(Box,62,12,5000);
}
if(LP1>=TP1*0.27){ //13
drawsprite(Box,64,12,5000);
}
if(LP1>=TP1*0.29){ //14
drawsprite(Box,66,12,5000);
}
if(LP1>=TP1*0.31){ //15
drawsprite(Box,68,12,5000);
}
if(LP1>=TP1*0.33){ //16
drawsprite(Box,70,12,5000);
}
if(LP1>=TP1*0.35){ //17
drawsprite(Box,72,12,5000);
}
if(LP1>=TP1*0.38){ //18
drawsprite(Box,74,12,5000);
}
if(LP1>=TP1*0.40){ //19
drawsprite(Box,76,12,5000);
}
if(LP1>=TP1*0.42){ //20
drawsprite(Box,78,12,5000);
}
if(LP1>=TP1*0.44){ //21
drawsprite(Box,80,12,5000);
}
if(LP1>=TP1*0.46){ //22
drawsprite(Box,82,12,5000);
}
if(LP1>=TP1*0.48){ //23
drawsprite(Box,84,12,5000);
}
if(LP1>=TP1*0.50){ //24
drawsprite(Box,86,12,5000);
}
if(LP1>=TP1*0.52){ //25
drawsprite(Box,88,12,5000);
}
if(LP1>=TP1*0.54){ //26
drawsprite(Box,90,12,5000);
}
if(LP1>=TP1*0.56){ //27
drawsprite(Box,92,12,5000);
}
if(LP1>=TP1*0.58){ //28
drawsprite(Box,94,12,5000);
}
if(LP1>=TP1*0.60){ //29
drawsprite(Box,96,12,5000);
}
if(LP1>=TP1*0.63){ //30
drawsprite(Box,98,12,5000);
}
if(LP1>=TP1*0.65){ //31
drawsprite(Box,100,12,5000);
}
if(LP1>=TP1*0.67){ //32
drawsprite(Box,102,12,5000);
}
if(LP1>=TP1*0.69){ //33
drawsprite(Box,104,12,5000);
}
if(LP1>=TP1*0.71){ //34
drawsprite(Box,106,12,5000);
}
if(LP1>=TP1*0.73){ //35
drawsprite(Box,108,12,5000);
}
if(LP1>=TP1*0.75){ //36
drawsprite(Box,110,12,5000);
}
if(LP1>=TP1*0.77){ //37
drawsprite(Box,112,12,5000);
}
if(LP1>=TP1*0.79){ //38
drawsprite(Box,114,12,5000);
}
if(LP1>=TP1*0.81){ //39
drawsprite(Box,116,12,5000);
}
if(LP1>=TP1*0.83){ //40
drawsprite(Box,118,12,5000);
}
if(LP1>=TP1*0.85){ //41
drawsprite(Box,120,12,5000);
}
if(LP1>=TP1*0.88){ //42
drawsprite(Box,122,12,5000);
}
if(LP1>=TP1*0.90){ //43
drawsprite(Box,124,12,5000);
}
if(LP1>=TP1*0.92){ //44
drawsprite(Box,126,12,5000);
}
if(LP1>=TP1*0.94){ //45
drawsprite(Box,128,12,5000);
}
if(LP1>=TP1*0.96){ //46
drawsprite(Box,130,12,5000);
}
if(LP1>=TP1*0.98){ //47 ... 47/48 ==0.9791666
drawsprite(Box,132,12,5000);
}
if(LP1>=TP1*1){ //48 ... maxhealth is total health... so... 48/48 = 1
drawsprite(Box,134,12,5000);
}
}
if(P2){
drawsprite(P2LBar, 178, 0, 1000);
drawsprite(CheckeredLifeBarBox,184,9,285);
// int MP2 = getentityproperty(P2, "mp");
int LP2 = getentityproperty(P2, "health");
int TP2 = getentityproperty(P2, "maxhealth");
int HP2 = 96*LP2/TP2;
drawbox(280-HP2,9,HP2,1,1800,rgbcolor(99,140,0),0);
drawbox(280-HP2,10,HP2,1,1800,rgbcolor(222,239,0),0);
drawbox(280-HP2,11,HP2,2,1800,rgbcolor(255,255,0),0);
drawbox(280-HP2,13,HP2,2,1800,rgbcolor(198,214,0),0);
//Zipper bars
//48 bars
if(LP2==1){
NULL();
}
if(LP2>=TP2*0.02){ //1 (e.g. 1/48 = 0.02)
drawsprite(Box,279,12,5000); //First bar;
}
if(LP2>=TP2*0.04){ //2 => 2/48 = 0.04
drawsprite(Box,277,12,5000);
}
if(LP2>=TP2*0.06){ //3
drawsprite(Box,275,12,5000);
}
if(LP2>=TP2*0.08){ //4
drawsprite(Box,273,12,5000);
}
if(LP2>=TP2*0.10){ //5
drawsprite(Box,271,12,5000);
}
if(LP2>=TP2*0.13){ //6
drawsprite(Box,269,12,5000);
}
if(LP2>=TP2*0.15){ //7
drawsprite(Box,267,12,5000);
}
if(LP2>=TP2*0.17){ //8
drawsprite(Box,265,12,5000);
}
if(LP2>=TP2*0.19){ //9
drawsprite(Box,263,12,5000);
}
if(LP2>=TP2*0.21){ //10
drawsprite(Box,261,12,5000);
}
if(LP2>=TP2*0.23){ //11
drawsprite(Box,259,12,5000);
}
if(LP2>=TP2*0.25){ //12
drawsprite(Box,257,12,5000);
}
if(LP2>=TP2*0.27){ //13
drawsprite(Box,255,12,5000);
}
if(LP2>=TP2*0.29){ //14
drawsprite(Box,253,12,5000);
}
if(LP2>=TP2*0.31){ //15
drawsprite(Box,251,12,5000);
}
if(LP2>=TP2*0.33){ //16
drawsprite(Box,249,12,5000);
}
if(LP2>=TP2*0.35){ //17
drawsprite(Box,247,12,5000);
}
if(LP2>=TP2*0.38){ //18
drawsprite(Box,245,12,5000);
}
if(LP2>=TP2*0.40){ //19
drawsprite(Box,243,12,5000);
}
if(LP2>=TP2*0.42){ //20
drawsprite(Box,241,12,5000);
}
if(LP2>=TP2*0.44){ //21
drawsprite(Box,239,12,5000);
}
if(LP2>=TP2*0.46){ //22
drawsprite(Box,237,12,5000);
}
if(LP2>=TP2*0.48){ //23
drawsprite(Box,235,12,5000);
}
if(LP2>=TP2*0.50){ //24
drawsprite(Box,233,12,5000);
}
if(LP2>=TP2*0.52){ //25
drawsprite(Box,231,12,5000);
}
if(LP2>=TP2*0.54){ //26
drawsprite(Box,229,12,5000);
}
if(LP2>=TP2*0.56){ //27
drawsprite(Box,227,12,5000);
}
if(LP2>=TP2*0.58){ //28
drawsprite(Box,225,12,5000);
}
if(LP2>=TP2*0.60){ //29
drawsprite(Box,223,12,5000);
}
if(LP2>=TP2*0.63){ //30
drawsprite(Box,221,12,5000);
}
if(LP2>=TP2*0.65){ //31
drawsprite(Box,219,12,5000);
}
if(LP2>=TP2*0.67){ //32
drawsprite(Box,217,12,5000);
}
if(LP2>=TP2*0.69){ //33
drawsprite(Box,215,12,5000);
}
if(LP2>=TP2*0.71){ //34
drawsprite(Box,213,12,5000);
}
if(LP2>=TP2*0.73){ //35
drawsprite(Box,211,12,5000);
}
if(LP2>=TP2*0.75){ //36
drawsprite(Box,209,12,5000);
}
if(LP2>=TP2*0.77){ //37
drawsprite(Box,207,12,5000);
}
if(LP2>=TP2*0.79){ //38
drawsprite(Box,205,12,5000);
}
if(LP2>=TP2*0.81){ //39
drawsprite(Box,203,12,5000);
}
if(LP2>=TP2*0.83){ //40
drawsprite(Box,201,12,5000);
}
if(LP2>=TP2*0.85){ //41
drawsprite(Box,199,12,5000);
}
if(LP2>=TP2*0.88){ //42
drawsprite(Box,197,12,5000);
}
if(LP2>=TP2*0.90){ //43
drawsprite(Box,195,12,5000);
}
if(LP2>=TP2*0.92){ //44
drawsprite(Box,193,12,5000);
}
if(LP2>=TP2*0.94){ //45
drawsprite(Box,191,12,5000);
}
if(LP2>=TP2*0.96){ //46
drawsprite(Box,189,12,5000);
}
if(LP2>=TP2*0.98){ //47
drawsprite(Box,187,12,5000);
}
if(LP2>=TP2*1){ //48
drawsprite(Box,185,12,5000);
}
}
}
void oncreate()
{
void P1LBar;
void P2LBar;
void Box;
void LP1;
void CheckeredLifeBarBox;
void Sel1; void Sel2; void Sel3; void Sel4; void Sel5; void Sel6; void Sel7; void Sel8; void Sel9;
Sel1 = loadsprite("data/bgs/select/select01.png");
Sel2 = loadsprite("data/bgs/select/select02.png");
Sel3 = loadsprite("data/bgs/select/select03.png");
Sel4 = loadsprite("data/bgs/select/select04.png");
Sel5 = loadsprite("data/bgs/select/select05.png");
Sel6 = loadsprite("data/bgs/select/select06.png");
Sel7 = loadsprite("data/bgs/select/select07.png");
Sel8 = loadsprite("data/bgs/select/select08.png");
Sel9 = loadsprite("data/bgs/select/select09.png");
setglobalvar("Sel1",Sel1);
setglobalvar("Sel2",Sel2);
setglobalvar("Sel3",Sel3);
setglobalvar("Sel4",Sel4);
setglobalvar("Sel5",Sel5);
setglobalvar("Sel6",Sel6);
setglobalvar("Sel7",Sel7);
setglobalvar("Sel8",Sel8);
setglobalvar("Sel9",Sel9);
P1LBar = loadsprite("data/sprites/playerhud/p1lifebar.png");
setglobalvar("P1LBar", P1LBar);
P2LBar = loadsprite("data/sprites/playerhud/p2lifebar.png");
setglobalvar("P2LBar", P2LBar);
Box = loadsprite("data/sprites/playerhud/box.png");
setglobalvar("Box", Box);
CheckeredLifeBarBox = loadsprite("data/sprites/playerhud/checkeredlifebar.png");
setglobalvar("CheckeredLifeBarBox",CheckeredLifeBarBox);
}
void ondestroy(){
void P1LBar = getglobalvar("P1LBar");
void P2LBar = getglobalvar("P2LBar");
void Box = getglobalvar("Box");
void CheckeredLifeBarBox = getglobalvar("CheckeredLifeBarBox");
if(Box){
free(P1LBar);
free(P2LBar);
free(Box);
free(CheckeredLifeBarBox);
setglobalvar("P1LBar", NULL());
setglobalvar("P2LBar", NULL());
setglobalvar("Box", NULL());
setglobalvar("CheckeredLifeBarBox",NULL());
}
void Sel1 = getglobalvar("Sel1");
void Sel2 = getglobalvar("Sel2");
void Sel3 = getglobalvar("Sel3");
void Sel4 = getglobalvar("Sel4");
void Sel5 = getglobalvar("Sel5");
void Sel6 = getglobalvar("Sel6");
void Sel7 = getglobalvar("Sel7");
void Sel8 = getglobalvar("Sel8");
void Sel9 = getglobalvar("Sel9");
free(Sel1);
free(Sel2);
free(Sel3);
free(Sel4);
free(Sel5);
free(Sel6);
free(Sel7);
free(Sel8);
free(Sel9);
setglobalvar("Sel1",NULL());
setglobalvar("Sel2",NULL());
setglobalvar("Sel3",NULL());
setglobalvar("Sel4",NULL());
setglobalvar("Sel5",NULL());
setglobalvar("Sel6",NULL());
setglobalvar("Sel7",NULL());
setglobalvar("Sel8",NULL());
setglobalvar("Sel9",NULL());
}
void playerNameScorePos(){
void p1Ent = getplayerproperty(0, "entity");
void p2Ent = getplayerproperty(1, "entity");
//char p1Score = getplayerproperty(p1Ent, "score");
int p1Score = getplayerproperty(0, "score"); //get calling players score
char p2Score = getplayerproperty(1, "score");
int hres = openborvariant("hresolution");
int xpos = openborvariant("xpos");
if(p1Score != NULL()){
float x = 206;
if(p1Score>999999999){
x = 134;
}
else if(p1Score>99999999){
x = 142;
}
else if(p1Score>9999999){
x = 150;
}
else if(p1Score>999999){
x = 158;
}
else if(p1Score>99999){
x = 166;
}
else if(p1Score>9999){
x = 174;
}
else if(p1Score>999){
x = 182;
}else if(p1Score>99){
x = 190;
}else if(p1Score>9){
x = 198;
}
drawstring(x, 85, 0, p1Score);
}
if(p1Ent != NULL()){ // When player 1 entity is not empty
char p1Name = getentityproperty(p1Ent, "name"); //Player 1 entity's name
char p1Score = getplayerproperty(p1Ent, "score"); //Player 1 entity's score
int p1NameX = getentityproperty(p1Ent, "x");
int p1NameZ = getentityproperty(p1Ent, "z");
int p1NameA = getentityproperty(p1Ent, "y");
}
if(p2Ent != NULL()){
char p2Name = getentityproperty(p2Ent, "name"); //Calling player 2's name
char p2Score = getplayerproperty(p2Ent, "score");
int p2NameX = getentityproperty(p2Ent, "x");
int p2NameZ = getentityproperty(p2Ent, "z");
int p2NameA = getentityproperty(p2Ent, "y");
/* if(p2Score){
drawstring(254,85,0,p2Score);
}*/
if(p2Name){
drawstring(hres-27-strwidth(p2Name, 0), 55, 0, p2Name);
}
}
}