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.draw: this.drawing) {
temp.plyr = temp.draw[0];
temp.img_index = temp.draw[1];
with (findimg(temp.img_index)) {
// Update position
x = temp.plyr.x;
y = 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(200, 0, 32 * 2, 32, 32);
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.