31


int currentFrame = 0;
PImage[] frames = new PImage[24];
int lastTime = 0;

void setup(){
size(400,400);

smooth();
background(255);
for(int i = 0; i < frames.length; i++){
frames[i] = get();
}
}

void draw(){
int currentTime = millis();
if(currentTime > lastTime + 30){
nextFrame();
lastTime = currentTime;
}
if(mousePressed == true){
stroke(random(255),random(255),random(255));
strokeWeight(random(6,12));
line(pmouseX,pmouseY,mouseX,mouseY);
}
}

void nextFrame(){
frames[currentFrame] = get();
currentFrame++;
if(currentFrame >= frames.length){
currentFrame = 0;
}
image(frames[currentFrame],0,0);
}

コメント