2018年10月25日 星期四

week07_焦焦焦

課堂作業(1)

血量、血條如何實作

(a)先畫出背景+一個方塊

int life=10;
void setup(){
  size(500,500);
}
void draw(){
  background(0,0,205);
  rect(50,50, 100,20);
}



(b)將方塊上色

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);
}



(c)當血條沒了,遊戲結束(顯示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;
}



課堂作業(2)

倒數計時如何實作

int state=0;
void setup(){
  size(800,600);
}
void draw(){
  if(state==0){
    drawOP();
    if(key=='1') state=1;
  }else if(state==1){
    drawPlayer();
  }else if(state==2){

  }
}
void drawPlayer(){
  background(#F0E90F);
  fill(#24E80C);
}
void drawOP(){
  background(0);
  fill(#0C39E8);
  textSize(30); text("Opening...You can press I to play",10,100);
}









沒有留言:

張貼留言