creeph[cloneindex]=health;
creepx[cloneindex]=x;
creepy[cloneindex]=y;
int i;
for (i=0; i<=100; i++){ // performs loop 100 times. The array size didn't matter as
//long as its larger than this.
if (creepx[i]!=0){ // if creepx[i] equaled zero, then the creep isn't alive,
//and we wouldn't want to draw. And any creep array
//would work; creepx, creepy, or creeph.
setpen(255,0,0, 0, 3);
moveto(creepx[i]-10, creepy[i]-25);
lineto((creepx[i]+10), creepy[i]-25); // This part draws the red background bar
setpen(0,255,0,0,3);
moveto(creepx[i]-10, creepy[i]-25);
testvar=rtb(creeph[i], thishealth, 20); // rtb is a function to return
//the health/distance (see below).
//var 'thishealth' is the creep starting
// health, same for all creeps but
//goes up each wave
lineto((creepx[i]-10)+testvar, creepy[i]-25); // This part draws the green bar
}
}
int rtb(float health, float maxhealth, int numbars)
{
return (int)((health*20)/maxhealth); //returns health as a range
// from zero to numbars(20)
} //numbars would need to be
//the length of the total bar we want to draw
//(20 in this case)
for (i=0; i<=100; i++){ // performs loop 100 times. The array size didn't matter as
for(i=0; i<sizeof(array)-1; i++)
Fuzzy wrote:See this line?
- Code: Select all
for (i=0; i<=100; i++){ // performs loop 100 times. The array size didn't matter as
Well, you can simplify it.
- Code: Select all
for(i=0; i<sizeof(array)-1; i++)
Users browsing this forum: No registered users and 1 guest