int N=4;
int score=0;
int []sequence=new int[1000];
int bloodA=125;
int bloodB=125;
float CarX=150;
float CarY=500;
float []thingX= new float[4], thingY= new float[4], thingType= new float[4];
PImage imgZombie;
PImage imgCar;
PImage imgStop;
PImage imgWork;
PImage imgRoad;
PImage imgPolice;
int stage=0;
void setup() {
size(500, 600);
imgZombie=loadImage("zombie.png");
imgCar=loadImage("car.gif");
imgWork=loadImage("work.gif");
imgStop=loadImage("http://www.jiaotongbiaopai.com/upfile/article/201362622221081709468.gif");
imgRoad=loadImage("http://image.cn.made-in-china.com/2f0j01hBuQCfSPJlrW/%E9%A9%AC%E8%B7%AF%E5%88%92%E7%BA%BF%E6%BC%86.jpg");
imgPolice=loadImage("http://pic3.nipic.com/20090602/2801713_220519017_2.jpg");
image(imgPolice, 500, 600);
image(imgRoad, 500, 600);
for (int i=0;i<N;i++) {
//sequence[i]=int (random(3)) ;
newThing(i);
}
}
//int now=0;
int countDown=5*30;
void keyPressed() {
if (keyCode==RIGHT) CarX+=40;
if (keyCode==LEFT) CarX-=40;
}
void newThing(int i) {
thingY[i]=-random(200);
thingX[i]=random(400);
thingType[i]=int(random(3))+1;
}
void drawZombie(int i ) {
fill(255, 0, 0);
image (imgZombie, thingX[i], thingY[i], 40, 60);
}
void drawStop (int i) {
fill (0);
image (imgStop, thingX[i], thingY[i], 40, 60);
}
void drawWork(int i) {
fill(#FF6803);
image (imgWork, thingX[i], thingY[i], 60, 60);
}
void draw() {
background(255);
switch(stage) {
case 0:
if (countDown>0) {
image(imgPolice, 0, 0, 500, 600) ;
countDown--;
textSize(30);
text("Are you ready?", 150, 250);
text("Start: "+countDown/30, 180, 300);
return ;
}
image(imgRoad, 0, 0, 500, 600);
// for(int i=0;i<N;i++){
// //image(imgZombie, sequence[i]*100, 400-(i-now)*100);
// }
for (int i=0;i<N;i++) {
if (thingType[i]==1)drawZombie(i);
else if (thingType[i]==2)drawStop(i);
else if (thingType[i]==3)drawWork(i);
thingY[i]+=4;
if (thingY[i]>500) newThing(i);
}
image(imgCar, CarX, CarY, 100, 100);
//for(int i=0;i<4;i++){
//score(i);
//}
fill(255,0,0);
rect(0,0,bloodA*2,50);
rect(250,0,bloodB*2,50);
}
}
沒有留言:
張貼留言