2024年1月11日 星期四

Sangmo 互動技術 Week16

 槍械選擇介面

增加一點遊戲變化性,人物可以選擇不同的槍來獲得不同的屬性加成

程式碼:
void choosegun(){
  background(#EAC566);
  
  fill(#52514C);
  PFont font = createFont("微軟正黑體 Bold",40);
  PFont font2 = createFont("微軟正黑體 Bold",20);
  textFont(font);
  fill(0);
  text("選擇槍械",525,100);
  fill(#1102F0);
  text("半自動步槍",50,220);
  text("自動步槍",320,220);
  text("衝鋒槍",680,220);
  text("狙擊步槍",950,220);
  fill(0);
  
  image(gunA,50,250,200,150); ///滑鼠移過去時會跑出槍械有什麼功能 
  if(mouseX > 50 && mouseX < 250 && mouseY > 250 && mouseY < 400){
    tint(#95948F, 255);
    image(gunA,50,250,200,150);
    noTint();
  }
  if(state==9 && mouseX > 50 && mouseX < 250 && mouseY > 250 && mouseY < 400){
    fill(255);
    rect(400,475,400,300,28);
    fill(0);
    textFont(font2);
    text("射擊速度稍微降低", 420,500);
    fill(#F77F7F);
    text("傷害稍微提升", 420,520);
    fill(0);
    text("玩家速度  "+pl.speed,420,600);
    text("玩家血量  "+pl.health,420,630);
    text("射擊傷害  15",420,660);
    text("射擊速度  每秒1.5發子彈",420,690);
    text("射擊距離  "+pl.space,420,720);
  }
  
  image(gunB,320,250,200,150);
  if(mouseX > 320 && mouseX < 520 && mouseY > 250 && mouseY < 400){
    tint(#95948F, 255);
    image(gunB,320,250,200,150);
    noTint();
  }
  if(state==9 && mouseX > 320 && mouseX < 520 && mouseY > 250 && mouseY < 400){
    fill(255);
    rect(400,475,400,300,28);
    fill(0);
    textFont(font2);
    text("屬性平均發展", 420,500);
    fill(#F77F7F);
    text("擊殺首個敵人時 立即獲得升級點", 420,520);
    fill(0);
    text("玩家速度  5",420,600);
    text("玩家血量  "+pl.health,420,630);
    text("射擊傷害  "+damageb,420,660);
    text("射擊速度  每秒3發子彈",420,690);
    text("射擊距離  "+pl.space,420,720);
  }
  image(gunC,680,250,200,150);
  if(mouseX > 680 && mouseX < 880 && mouseY > 250 && mouseY < 400){
    tint(#95948F, 255);
    image(gunC,680,250,200,150);
    noTint();
  }
  if(state==9 && mouseX > 680 && mouseX < 880 && mouseY > 250 && mouseY < 400){
    fill(255);
    rect(400,475,400,300,28);
    fill(0);
    textFont(font2);
    text("射擊距離與槍械傷害降低", 420,500);
    fill(#F77F7F);
    text("玩家速度與射擊速度皆大幅提升", 420,520);
    fill(0);
    text("玩家速度  5",420,600);
    text("玩家血量  "+pl.health,420,630);
    text("射擊傷害  8",420,660);
    text("射擊速度  每秒6發子彈",420,690);
    text("射擊距離  150.0",420,720);
  }
  image(gunE,950,250,200,150);
  if(mouseX > 950 && mouseX < 1050 && mouseY > 250 && mouseY < 400){
    tint(#95948F, 255);
    image(gunE,950,250,200,150);
    noTint();
  }
  if(state==9 && mouseX > 950 && mouseX < 1050 && mouseY > 250 && mouseY < 400){
    fill(255);
    rect(400,475,400,300,28);
    fill(0);
    textFont(font2);
    text("玩家血量與玩家速度與射擊速度降低", 420,500);
    fill(#F77F7F);
    text("射擊距離與槍械傷害大幅提升", 420,520);
    fill(0);
    text("玩家速度  2",420,600);
    text("玩家血量  50",420,630);
    text("射擊傷害  30",420,660);
    text("射擊速度  每秒1發子彈",420,690);
    text("射擊距離  500.0",420,720);
  }
}

執行畫面
選到槍時
會跳出白色框說明選擇後獲得的屬性

沒有選到槍時

選完槍會跳到選擇地圖

地圖選擇介面加上遊戲操作說明



沒有留言:

張貼留言