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(0);
fill(#F0D90C);text("Game Over",100,100);
}
void drawPlayer()
{
background(0);
fill(#161FF2);text("Playing... You can press 2 to End",10,100);
text("remain:"+remainTime,10,200);
remainTime--;
if(remainTime<=0) state=2;
}
void drawOP()
{
background(0);
fill(#F5DE07);
textSize(30);text("Opening... You can press 1 to play",10,100);
}
沒有留言:
張貼留言