var pic1 var pic2 etc . . . var frame = 1; //Default value is start of animation sequence var frameSpeed = 10; //Number of paint redraws before frame counts up var frameCool = frameSpeed; //Counter to keep trck of how long the current frame has been up //Setting it to frame speed begins the cooldown right away var maxFrame = 7; //Is the number of animation frames function paint { /////////////////////////// // Frame cooldown code if (frameCool > 0) //Count down if frameCool is bigger than zero, and will keep counting until it is zero { frameCool -= 1; }else //This part happens when frameCool finally makes it to zero { frameCool = frameSpeed; //reset frameCool to begin again frame += 1; //Move to the next animation frame } if (frame > maxFrame){frame = 1;} //Restarts the animation by setting frame back to start after animatin is done if (frame == 1){ctx.drawImage(pic1, 100, 100);} else if(frame == 2){ctx.drawImage(pic[2], 100, 100);} else if(frame == 3){ctx.drawImage(pic3, 100, 100);} else if(frame == 4){ctx.drawImage(pic4, 100, 100);} else if(frame == 5){ctx.drawImage(pic5, 100, 100);} else if(frame == 6){ctx.drawImage(pic6, 100, 100);} else if(frame == 7){ctx.drawImage(pic7, 100, 100);} ctx.drawImage }