2018年10月25日 星期四

Week07昱霖的筆記

做出血條(HP0)
int life=10;
void setup(){
  size(500,500);
}
void draw(){
  background(0,0,205);
  rect(50,50,100,20);
}
血條(HP100)
int life=10;
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);
}
點擊滑鼠會造成扣血
void mousePressed(){
  life--;
}

HP歸零顯示Game Over
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;
}

沒有留言:

張貼留言