Jessica - M

By Jessica Thornburgh
int numDragons = 20; Dragon[] dragons = new Dragon[numDragons]; PImage fire; int numFrames = 17; int frame = frameCount % numFrames; PImage [] images = new PImage[numFrames]; void setup () { size(600, 400); smooth(); frameRate(20); noStroke(); fire = loadImage("fire.gif"); for (int i = 0; i < images.length; i++) { String imageName = "dwing" + nf(i+1, 2) + ".gif"; images[i] = loadImage(imageName); } for (int i = 0; i < dragons.length; i++) { float x = (int)random(0, 600); float y = (int) random(0, 400); float h = (int)random(50, 200); float w = 0.7*h; dragons[i] = new Dragon(x, y, 50, 100); } } void draw() { fill(255, 150); rect(0,0, width, height); for (int i = 0; i < dragons.length; i++) { dragons[i].display(); dragons[i].move(); } } class Dragon { // float w, h; float x = (int)random(0, 600); float y = (int) random(0, 400); float h = (int)random(50, 200); float w = 0.7*h; Dragon(float xpos, float ypos, float win, float hin) { x = xpos; y = ypos; w = win; h = hin; } void display() { int frame = frameCount % numFrames; float h = .5*mouseX; float w = 0.7*h; image(images[frame], x , y , w, h); if (mousePressed == true) { image(fire, x-.28*h, y+.27*h, .28*h, .14*h); } } void move() { x = x-1.5; y = y-.5; if (x<0 || x > 600 || y<0 || y>400) { x=600; y=(int)random(0,400); } } }

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*