組員:鄭祥斌 99163116
期中作品展示
程式碼
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(0,220,0);
rect(0,0,bloodA*2,50);
fill(255,220,0);
rect(250,0,bloodB*2,50);
}
}
遊戲介紹
透過接收各種的標誌來了解交通標誌,因此有一台小汽車可利用鍵盤移動,接從上方掉下的交通號誌,左上的方條為汽車的生命值,右上方的為所剩時間,假如碰撞到的障礙物越多,他的生命質就越低,本遊戲的方數計算為100-綠色長方條後的分數,所以生命值越低分數就越高。
心得
特過這次製作的小遊戲,讓我們能夠了解processing的語法和運作,同時兼具教育和娛樂的實用性,在製作過程中有很多bug出現,為了能製作出好玩遊戲努力的克服了,雖然最後程式仍然有些許的bug但不影響遊戲運作,在寫作業中找到了很大的成就感,老師透過評分的方式,讓大家看到不同創意展現,因此在日後結合硬體操作的遊戲上,更令人期待能設計出什麼更棒的遊戲內容。
沒有留言:
張貼留言