--------- processing
Dino dino;
boolean run;
void setup(){
size(640, 480);
background(0);
frameRate(30);
run = false;
}
void draw(){
background(0);
if(run){
dino.run();
if(dino.frame >= 7){
run = false;
}
}
}
class Dino{
PImage[] images;
int imageCount;
int frame;
float x, y;
Dino(float x, float y){
this.x = x;
this.y = y;
imageCount = 8;
frame = 0;
images = new PImage[imageCount];
for(int i = 0; i < imageCount; i++){
String filename = "png/Run ("+i+").png";
images[i] = loadImage(filename);
images[i].resize(680/2, 472/2);
}
}
void run(){
image(images[frame], this.x, this.y);
frame = (frame + 1) % imageCount;
delay(70);
}
}
void mousePressed(){
dino = new Dino(mouseX - 150, mouseY - 100);
run = true;
}
----------------