Thread: Health bar
View Single Post
  #15  
Old 11-04-2011, 04:11 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You're looping through each player and only using the element 1 in the array. I believe there was an error in my code unfortunately I can't go back and edit it now.

In your drawing function record the following in an array:

this.drawing.add({temp.p, 200 + temp.i});

In your updating function loop through your drawing array:

PHP Code:
for (temp.drawthis.drawing) {
  
temp.plyr temp.draw[0];
  
temp.img_index temp.draw[1];
  
with (findimg(temp.img_index)) {
    
// Update position
    
temp.plyr.x;
    
temp.plyr.y;
  }
  
with (findimg(temp.img_index 1)) {
    
// Update position
  
}

Also just some small optimizations/changes you can make as well:

1. Store the width and height of your bar graphics in a variable outside the loop. Calling getimgwidth and getimgheight repeatedly isn't needed.
2. Use partx, party, partw, and parth instead of changeimgpart since you're already using findimg in a with statement.

PHP Code:
// Using part in findimg assignments
with (findimg(200)) {
  
image "head0.png";
  
partx 0;
  
party = (32 2);
  
partw 32;
  
parth 32;
}
// Same thing as doing:
changeimgpart(200032 23232); 
3. Be more consistent when using temp. In the same line you use it with and without the prefix. Avoid setting global variables (your line part=math+blah that don't need to be global. You can do that by putting temp. I.e: temp.part.
__________________
Quote:
Reply With Quote