作品簡介
我們製作了開始的畫面並說明按鍵的功能,點擊任意處即可開始遊玩,玩法為點按鍵盤對應的鼓即可獲得分數,達到880分即可過關,遊戲附帶音樂的功能,點按鼓時會發出鼓聲,並有怪物出現影響視線。
遊戲的畫面:
code:
import processing.sound.*;
SoundFile sound1;
SoundFile D1;
SoundFile D2;
SoundFile D3;
PImage imgUI, imgM1 ,imgM2 ,imgM3,imgTAB,imgM4,imgOPEN;
int [] array = { 26,27,28,35,44,45,56,57,61,77,82,88,91,100,101,103,119,120,125,131,133,140,141,143,150,158,166,167,169,185,186,188,189,192,194};
int [] array2 = {18,31,32,36,41,46,49,62,68,69,70,78,79,80,86,97,111,112,117,122,123,124,138,144,146,153,160,162,172,175,177,179,187};
int [] array3 = {22,24,37,40,42,43,50,55,58,59,60,83,90,95,99,105,110,115,118,121,134,136,137,142,149,155,157,165,173,181,182};
int score=0;
int stage=1;
void setup(){
size(1089,577);
imgUI = loadImage("ui2.png");
imgM1 = loadImage("m1.png");
imgM2 = loadImage("m2.png");
imgM3 = loadImage("m3.png");
imgM4 = loadImage("m4.png");
imgTAB = loadImage("tab.png");
imgOPEN = loadImage("open.png");
sound1 =new SoundFile(this,"Super Mario Bros. Theme Song.mp3");
D1=new SoundFile(this,"d1.wav");
D2=new SoundFile(this,"d2.wav");
D3=new SoundFile(this,"d3.wav");
}
float cd=0;
float cd2=0;
void draw(){
if(stage==1){
background(imgOPEN);
fill(255,0,0);textSize(40);
text(" Red=D ",180,180);
fill(0,217,0);textSize(40);
text(" Green=SPACE ",180,220);
fill(0,0,255);textSize(40);
text(" Blue=J ",180,260);
fill(250,124,0);
rect(430,150,220,100);
fill(0,0,0);textSize(80);
text(" START ",420,230);
}
if(stage==2){
if (frameCount==60*5){
sound1.play();
}
background(imgUI);
for(int i=0; i < array.length; i++){
float x = 810 + array[i]*90 - cd;
image(imgM1, x,165);
if( 290 < x+37 && x+37 < 375 && keyPressed && key=='d'){
D1.play();
score+=10;
array[i] = -30;
}
}
for(int i=0; i < array2.length; i++){
float x = 810 + array2[i]*90 - cd;
image(imgM2, x,165);
if( 290 < x+37 && x+37 < 375 && keyPressed && key==' '){
D2.play();
score+=10;
array2[i] = -30;
}
}
for(int i=0; i < array3.length; i++){
float x = 810 + array3[i]*90 - cd;
image(imgM3, x,165);
if( 290 < x+37 && x+37 < 375 && keyPressed && key=='j'){
D3.play();
score+=10;
array3[i] = -30;
}
}
for(int i=0; i < array.length; i++){
float x = 810 + array[i]*90 - cd2;
image(imgM4, x,165);
}
image(imgTAB, 0,150);
cd = 100.0/500*millis();
cd2=150.0/500*millis();
fill(255);textSize(80);
text(""+score,730,80);
if (score>=850 ){
fill(255,0,0);textSize(50);
text("AMAZING!!",750,145);
}
}
}
void mousePressed(){
if(stage==1) stage=2;
}


沒有留言:
張貼留言