Page 1 of 1

Multiple Health Bar trouble

PostPosted: Thu Apr 14, 2011 12:01 am
by Irondan75
So I have a main level and a Boss Battle level each in its own region. My main level has a player health bar that works great. My Boss level has a player bar and Boss bar,
my boss bar registers damage fine but my player bar does not. I scripted like this:

//main player

erase(0, 0, 0, 1);
for (i=0;i<maxhp;i++)
{
setpen(180, 0, 0, 0, 1);
moveto(i, 0);
lineto(i, height-1);
}
for (i2=0;i2<hp;i2++)
{
setpen(0, 0, 255, 0, 1);
moveto(i2, 0);
lineto(i2, height-1);
}


//Player in Boss level

erase(0, 0, 0, 1);
for (i=0;i<maxhp1;i++)
{
setpen(180, 0, 0, 0, 1);
moveto(i, 0);
lineto(i, height-1);
}
for (i2=0;i2<hp1;i2++)
{
setpen(0, 0, 255, 0, 1);
moveto(i2, 0);
lineto(i2, height-1);
}


//Boss enemy


erase(0, 0, 0, 1);
for (i=0;i<bossmaxhp;i++)
{
setpen(180, 0, 0, 0, 1);
moveto(i, 0);
lineto(i, height-1);
}
for (i2=0;i2<bosshp;i2++)
{
setpen(0, 0, 255, 0, 1);
moveto(i2, 0);
lineto(i2, height-1);
}


I have checked over and over my scripts in my player and enemy collision,draw,create scripts and they look fine.
I have the hp,hp1,maxhp,maxhp1,bosshp and bossmaxhp set in global variables...so I dont know what to look for next?

Is it possible to have two working health bars on one level?

Re: Multiple Health Bar trouble

PostPosted: Thu Apr 14, 2011 12:26 am
by skydereign
It is definitely possible, pretty much anything is. I'd suggest using only one player hp variable. Currently you have hp1 and hp. With this, you will have to code for dealing damage to two hp variables, where only one is required. The problem you are having sounds like you aren't lowering hp1 when you should. A good way to figure out what exactly is happening is to use text actors and display the variable values.

Re: Multiple Health Bar trouble

PostPosted: Thu Apr 14, 2011 11:16 am
by Irondan75
So I changed the hp1 and maxhp1 to str and strmax and got the same results. So I set the boss collision to my player as str-=10; and my player bar registers damage.
Why the boss bullet collision cant register but the boss collision can is odd :?

Re: Multiple Health Bar trouble

PostPosted: Thu Apr 14, 2011 7:04 pm
by skydereign
Not really sure what to tell you. I can get it to work, using the same code for either the boss collision or the bullet collision. Would you mind posting the source? It doesn't have to be the full ged, just enough to show the problem.

Re: Multiple Health Bar trouble

PostPosted: Thu Apr 14, 2011 7:18 pm
by Irondan75
Thanks for the offer and prior help Skydereign, but I always get an error when I log into the forum (Error: Permission to upload files denied.)
It's ok though, I just changed the end Boss fight to a cool path pattern the player needs to avoid while shooting back to destroy the Boss and it works pretty good with the flow of the game.

Gonna try to get it up in the Apple Store to see how it does.