• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Solved How do i make it load the sprites once instead of everytime?

Question that is answered or resolved.

NONAME01150

New member
I tried to have a check in update.c but it just ends up with an error.
void main()
{

void P1 = getplayerproperty(0, "entity");
int HP = getentityproperty(P1, "health");
int MP = getentityproperty(P1, "mp");
int Lives = getplayerproperty(P1, "lives");
int Score = getplayerproperty(P1, "score");
void Hud = getglobalvar("Health1");
if (Hud == NULL())
{
void Health1 = loadsprite("data/sprites/HealthBar1.png");
void Health2 = loadsprite("data/sprites/HealthBar2.png");
setglobalvar("Health1", Health1);
setglobalvar("Health2", Health2);
}

if(openborvariant("in_level")){
drawbox(0,0,256,47,1000,rgbcolor(0,0,0),0);
drawstring(0, 0, 2, "SCORE-_" + Score, 1001);
drawstring(0, 10, 2, "PLAYER", 1001);
drawsprite(Health2, 48, 10, 1001, 1);
drawsprite(Health2, 48+4, 10, 1001, 1);
drawsprite(Health2, 48+8, 10, 1001, 1);
drawsprite(Health2, 48+12, 10, 1001, 1);
drawsprite(Health2, 48+16, 10, 1001, 1);
drawsprite(Health2, 48+20, 10, 1001, 1);
drawsprite(Health2, 48+24, 10, 1001, 1);
drawsprite(Health2, 48+28, 10, 1001, 1);
drawsprite(Health2, 48+32, 10, 1001, 1);
drawsprite(Health2, 48+36, 10, 1001, 1);
drawsprite(Health2, 48+40, 10, 1001, 1);
drawsprite(Health2, 48+44, 10, 1001, 1);
drawsprite(Health2, 48+48, 10, 1001, 1);
drawsprite(Health2, 48+52, 10, 1001, 1);
drawsprite(Health2, 48+56, 10, 1001, 1);
drawsprite(Health2, 48+60, 10, 1001, 1);

if(HP>=1){
drawsprite(Health1, 48, 10, 1001, 2);
}
if(HP>=2){
drawsprite(Health1, 48+4, 10, 1001, 2);
}
if(HP>=3){
drawsprite(Health1, 48+8, 10, 1001, 2);
}
if(HP>=4){
drawsprite(Health1, 48+12, 10, 1001, 2);
}
if(HP>=5){
drawsprite(Health1, 48+16, 10, 1001, 2);
}
if(HP>=6){
drawsprite(Health1, 48+20, 10, 1001, 2);
}
if(HP>=7){
drawsprite(Health1, 48+24, 10, 1001, 2);
}
if(HP>=8){
drawsprite(Health1, 48+28, 10, 1001, 2);
}
if(HP>=9){
drawsprite(Health1, 48+32, 10, 1001, 2);
}
if(HP>=10){
drawsprite(Health1, 48+36, 10, 1001, 2);
}
if(HP>=11){
drawsprite(Health1, 48+40, 10, 1001, 2);
}
if(HP>=12){
drawsprite(Health1, 48+44, 10, 1001, 2);
}
if(HP>=13){
drawsprite(Health1, 48+48, 10, 1001, 2);
}
if(HP>=14){
drawsprite(Health1, 48+52, 10, 1001, 2);
}
if(HP>=15){
drawsprite(Health1, 48+56, 10, 1001, 2);
}
if(HP>=16){
drawsprite(Health1, 48+60, 10, 1001, 2);
}

}
}

edit: Managed to make it work by putting the "loadsprite"s and "setglobalvar"s into "level.c".
 
Last edited:
Dude, it would be better you post your codes like the first one here. Why using the inline code for posting the whole code? If you are going to post scripts like you have there, put it to C in language. If not, while it's just a general code from .txt files, leave it general.

 
Back
Top Bottom