PImage img;
int rx=28,ry=5;
boolean move = true;
void setup() {
size(400, 400);
img = loadImage("path.jpg");
}
void draw() {
image(img, 0, 0);
loadPixels();
fill(225, 0, 0);//點點
ellipse(rx, ry, 10, 10);
if (move==true) {
if(key==97) rx=rx-1;
if(key==119) ry=ry-1;
if(key==100) rx=rx+1;
if(key==115) ry=ry+1;
}
color now_color = pixels[ry*400+rx];
if (rx>398){
rx=398;
fill(0, 0, 0);
rect(0, 0, 400, 400);
textSize(50);
fill(255, 255, 0);
text("Congratulation", 25, 220);
}
if (red(now_color)<100){
move = false;
fill(0, 0, 0);
rect(0, 0, 400, 400);
textSize(50);
fill(255, 255, 0);
text("GAME OVER", 60, 220);
}
else move = true;
}
沒有留言:
張貼留言