🔺血量
int life=10;boolean gameOver=false;
void setup(){
size(500,500);
}
void draw(){
background(0,0,205);
fill(255);rect(50,50,100,20);
fill(255,0,0); rect(50,50,life*10,20);
if(gameOver){
textSize(40);
text("Game Over",150,150);
}
}
void mousePressed(){
life--;
if(life<=0) gameOver=true;
}
🔺倒數
int state=0;
int remainTime=0;
void setup(){
size(800,600);
}
void draw(){
if(state==0){
drawOP();
if(key=='1'){
state=1;
remainTime=5*60;
}
}else if(state==1){
drawPlayer();
}else if(state==2){
drawED();
}
}
void drawED(){
background(#A2BCFF);
fill(#112AF7);
textSize(30);text("Game Over",100,100);
}
void drawPlayer(){
background(#ECFF5D);
fill(#0FFFFD);
textSize(30);text("Playing.. You can press 2 to play",10,100);
text("remail: "+remainTime,10,200);
remainTime--;
if(remainTime<=0) state=2;
}
void drawOP(){
background(0);
fill(#C61C1C);
textSize(30);text("Opening.. You can press 1 to play",10,100);
}
沒有留言:
張貼留言