2018年12月21日 星期五
week08_鄭昕恬
https://www.youtube.com/watch?v=KYo2-kWQnAU
操作模式:
進到遊戲畫面後,點'1'開始遊戲,利用滑鼠控制忍者左右移動,
並按滑鼠左右鍵向惡鬼射出刀子,右下有個魔力條,當魔力用光
就輸了遊戲,而當殺鬼的分數到達設定值時,即遊戲勝利。
遊戲賣點:
利用可愛的忍者角色,結合最近的萬聖節,組合成一個有趣的組合
在符合氣氛的背景還有音效下,玩著此遊戲很符合過節的氣氛,雖
然遊戲名"砍殺惡鬼"聽起來帶有恐怖的感覺,但事實上卻是個可愛
趣味的遊戲。
程式碼:
import ddf.minim.*;
Minim minim;
AudioPlayer player;
PImage img;
PImage ninja;
PImage ninja01;
PImage ninja02;
PImage background02;
PImage background01;
PImage bullet;
PImage[] imgN=new PImage[10];
PImage monster;
int[]monsterlife=new int[100];
float[]bulletX =new float[100];
float[]bulletY =new float[100];
boolean []bulletAlive =new boolean[100];
float [] monsterX = new float[100];
float [] monsterY = new float[100];
boolean[] monsterDie= new boolean[100];
boolean win =false;
boolean lose = false;
int life=100;
float[]lineY=new float[1];
int state=0;
void setup() {
minim= new Minim(this);
player=minim.loadFile("music.mp3");
player.play();
player.loop();
size(800, 600);
for (int i=0; i<=9; i++) imgN[i] = loadImage(i+".png");
background01=loadImage("background.jpg");
background02=loadImage("background01.png");
ninja=loadImage("ninja.png");
ninja01=loadImage("ninja01.png");
ninja02=loadImage("ninja02.png");
bullet=loadImage("bullet.png");
img=loadImage("soldier.png");
monster=loadImage("monster.png");
for (int i=0; i<100; i++) {
monsterX[i]=random(0, 600);
monsterY[i]=random(-1000, 2);
monsterlife[i]=1;
monsterDie[i]=false;
}
}
void draw() {
if(state==0){
drawOP();
if(key=='1')state=1;
}
else if(state==1){
drawPlayer();
}
}
boolean flying=false;
int score=0;
void drawPlayer(){
background(255);
image(background01, 0, 0, 800, 600);
fill(255);rect(630,480,100,20);
fill(0,0,255);rect(630,480,life*1,20);
//fill(255);rect(0,450,900,1);
stroke(255);
fill(255);
image(img, mouseX-10, 450, 100, 150);
for (int i=0; i<100; i++) {
if (monsterDie[i])continue;
image(monster, monsterX[i], monsterY[i], 90, 100);
monsterY[i]+=1;
// if (monsterY[i]>700) monsterY[i]=-2000+600;
// if(monsterY[i]<lineY)life--;
}
for (int b=0; b<100; b++) {
if (bulletAlive[b]) {
fill(255, 255, 0);
image(bullet, bulletX[b], bulletY[b], 60, 60);
bulletY[b]-=7;
for (int i=0; i<100; i++) {
if (monsterX[i]<bulletX[b]&&bulletX[b]<monsterX[i]+40 && abs(bulletY[b]-monsterY[i])<30) {
monsterlife[i]=0;
score+=100;
bulletAlive[b]=false;
monsterDie[i]=true;
}
//fill(255);rect(630,480,100,20);
//fill(255,0,0);rect(630,480,life,20);
//if(monsterY[i]>500)life--;
}
}
}
int now=score;
for (int i=0; i<5; i++) {
image(imgN[(now%10)], 720-i*30, 520, 40, 40);
now/=10;
}
//int now=blood;
if (win) {
background(255, 255, 255);
image(background02, 0, 0, 800, 600);
image(ninja, 100, 100, 300, 300);
textSize(80);
fill(255, 0, 0);
text("YOU WIN!", 300, 300);
}
if (lose) {
background(255, 255, 255);
image(background02, 0, 0, 800, 600);
image(ninja01, 100, 100, 300, 300);
textSize(80);
fill(255, 0, 0);
text("YOU LOSE!", 300, 300);
}
}
void drawOP(){
background(255);
image(background01, 0, 0, 800, 600);
image(ninja02, 300, 150, 200, 300);
text("you can press 1 to play...",170,240);
textSize(40);
fill(#8E7366);
}
void mousePressed() {
life-=3;
if (score>2000)win=true;
if(life<0)lose=true;
for (int now=0; now<100; now++) {
if (bulletAlive[now] ==false) {
bulletX[now]=mouseX;
bulletY[now]=450;
bulletAlive[now]=true;
break;
}
}
}
遭遇困難:
我想最大的困難就是從無到有吧,從一開始沒什麼想法,到參考老師
的各種影片,把影片中的一些重點與自己的遊戲互相配合,從每個教學
影片都學到不同技巧,不管是有關場景還是遊戲中的偵測等等,寫出一個
遊戲真不是那麼容易,但也不像想像中那麼難,除了要一直創新和除錯
也要與共同的組員相互討論,還好最後還是靠著老師的影片、同學的發問
,在這之中了解了許多要點,才因此寫出屬於自己的遊戲。
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言