PImage dragon;
PImage fire;
int numFrames = 17;
PImage[ ] images = new PImage[numFrames];
Dragon d1;
void setup() {
size(600, 400);
frameRate(20);
smooth();
noStroke();
dragon = loadImage("dragon.png");
fire = loadImage("fire.gif");
d1 = new Dragon(dragon, 50, 50 , 150, 200);
for (int i = 0; i < images.length; i++) {
String imageName = "dwing" + nf(i+1, 2) + ".gif";
images[i] = loadImage(imageName);
}
}
void draw() {
background(255);
d1.display();
}
class Dragon {
float moveX, moveY, w, h;
PImage p;
Dragon(PImage pic, float xpos, float ypos, float win, float hin) {
moveX = xpos;
moveY = ypos;
p = pic;
w = win;
h = hin;
}
void display () {
int frame = frameCount % numFrames;
image(images[frame], mouseX, mouseY , 150, 200);
if (mousePressed == true) {
image(fire, mouseX - 73, mouseY + 55, 80, 40);
}
}
}
Jessica - L
on Monday, Nov 24, 2008 – 5:05 am