I created the desired fill effect, but I hit another snag. I want to break the loop when 'this.current' is equal to 'this.final', but with how the math is done 'this.current' is always going to be off by a few fractions of a decimal. How can I get around this without messing with how fluid the animation is?
PHP Code:
// Created by maximus_asinus
//#CLIENTSIDE
function onPlayerChats() {
if (player.chat == "debug") {
this.final = {9,39,47,39,47,27,55,27,55,47,9,47};
this.current = {11,41,49,41,49,29,53,29,53,45,11,45};
player.chat = " ";
showpoly(200,this.current);
changeimgcolors 200,0,0,1,0.75;
setTimer(0.05);
}
}
function onTimeout() {
for (i=0;i<13;i++;) {
temp.distx = this.final[0+i] - this.current[0+i];
temp.disty = this.final[1+i] - this.current[1+i];
temp.movelength = (temp.distx * temp.distx + temp.disty * temp.disty) ^ 0.5;
temp.distx = temp.distx / temp.movelength;
temp.disty = temp.disty / temp.movelength;
this.current[0+i] = this.current[0+i] + temp.distx * 0.05;
this.current[1+i] = this.current[1+i] + temp.disty * 0.05;
showpoly(200,this.current);
i++;
setTimer(0.05);
}
}