class Butterfly { /// butterfly frames /////// int numFrames = 13; // The number of frames in the animation int frame = 0; PImage[] images = new PImage[numFrames]; float bx = width / 2; float by = height / 2; Butterfly () { images[0] = loadImage("1.png"); images[1] = loadImage("2.png"); images[2] = loadImage("3.png"); images[3] = loadImage("4.png"); images[4] = loadImage("5.png"); images[5] = loadImage("6.png"); images[6] = loadImage("7.png"); images[7] = loadImage("8.png"); images[8] = loadImage("9.png"); images[9] = loadImage("10.png"); images[10] = loadImage("11.png"); images[11] = loadImage("12.png"); images[11] = loadImage("13.png"); images[12] = loadImage("14.png"); } void flap () { /// BUTTERFLY ANIMATION /////////// bx += 8; by -= 8; frame = (frame+1)%numFrames; // Use % to cycle through frames tint (255, 0, 0); // fill (255, 111, 0); image(images[frame], bx, by, 114, 80); // 114 x 80 // fill (255, 111, 0, 90); //tint (256, 256, 256, 80); // image(images[frame], bx-5, by-5, 124, 90); /////////////////////////////////////////// if (bx > width*2) { bx = 0; } if (by> height*2) { by =0; } if (by < 0) { by = height; } if (bx < 0) { bx = width; } } }