期中作品檔案下載 SKYDRIVE
期中DEMO影片
截圖:
開頭動畫(含音樂)
人物每次都會不同,點擊滑鼠可以SKIP動畫
遊戲選單
上面是新遊戲、下面是說明頁面
左下可以切換/關閉音樂、右下可以離開遊戲
按鈕有點擊音效,及圖片變換
說明頁面
可以點擊箭頭換頁
人物選擇
使用滑鼠點擊選擇人物,人物在滑鼠移到上面時會動作
按下R鍵某人物會出現隱藏版
左方可以隨機選角(含第二位隱藏人物)
場景選擇
使用滑鼠點擊選擇場景,場景為半透明
在滑鼠移到上面時會恢復正常
遊戲畫面
使用發射人物飛行,距離越遠時間越長越好
下方怪物可以改變方向及速度
有兩種特殊怪物
對某類怪物撞擊一定數量可以發動COMBO(共3種
遊戲結束
人物完全停止時結束,此時右下按鍵不再是強行結束
而會進到紀錄頁
紀錄頁
顯示本次成績及最佳成績
程式碼:
//音樂宣告 import ddf.minim.*; Minim minim; AudioPlayer effect0;//開場音樂 AudioPlayer effect1;//點擊音效 AudioPlayer bgm0;//背景音樂1 AudioPlayer bgm1;//背景音樂2 AudioPlayer bgm2;//背景音樂3 //圖片宣告 PImage[][] character = new PImage[20][6];//人物 PImage[][] monster = new PImage[20][6];//怪物 PImage[] title = new PImage[3];//遊戲畫面 PImage[] stage = new PImage[4];//遊戲場景 PImage[] num = new PImage[10];//遊戲場景 PImage[][] button = new PImage[2][3];//選單按鈕 PImage[][] item = new PImage[2][2];//道具按鈕 PImage[] sound = new PImage[2];//音樂開關 PImage[] arrow = new PImage[2];//上下箭頭 PImage[] help = new PImage[3];//說明 PImage[] playing = new PImage[3];//播放中 PImage score,time,dotImage,xx;//分數,時間,冒號,乘號 PImage gameover;//遊戲結束 PImage Uimg,Dimg,Simg,Cimg;//上,下,特殊,連擊 PImage left,right,home;//左右按鈕,回主畫面 PImage endgame,randomcharacter;//離開遊戲,隨機人物 //字型宣告 PFont Font0,Font1; //變數宣告 int nowtitle=0,nowstage=0;//顯示畫面,顯示場景 int nowcharacter,nowmonster;//顯示人物,顯示怪物 float characterX=0,characterY=500;//人物位置 float vx,vy;//人物速度 float g=0.1;//場景重力 float stageX,startX;//場景位移,怪物位移 float[] monsterX = new float[20];//怪物位置 int m,saver,savedtime;//計時器 int select;//隨機 int ucount=3,dcount=3;//道具殘量 int shot=0,timeover;//板機,強制結束 int combo[] = new int[3]; int page,mute,nowbgm;//頁數,靜音,現正播放 int nowscore,nowtime;//現在時間,現在分數 int oldtime,oldscore; //檔案 PrintWriter output,output2; BufferedReader reader,reader2; String line,line2; //初始設定 void setup(){ size(1280,720);//視窗大小 // reader = createReader("/data/score.txt"); reader2 = createReader("/data/time.txt"); //載入圖片 for(int i=0;i<20;i++){ for(int j=0;j<6;j++){ character[i][j] = loadImage("/graphic/character/Frame"+i+"_"+j+".png");//人物 monster[i][j] = loadImage("/graphic/monster/Frame"+i+"_"+j+".png");//怪物 if(i<2&&j<3) button[i][j] = loadImage("/graphic/button/button"+i+"_"+j+".png");//選單按鈕 if(i<2&&j<2) item[i][j] = loadImage("/graphic/button/item"+i+"_"+j+".png");//道具按鈕 } monsterX[i]=monsterX[i]=320+random(5120);//怪物位置 if(i<3){ title[i] = loadImage("/graphic/title/title"+i+".png");//畫面 help[i] = loadImage("/graphic/help/help"+i+".png");//畫面 playing[i] = loadImage("/graphic/button/"+(i+1)+".png");//播放中 } if(i<2){ sound[i] = loadImage("/graphic/button/sound"+i+".png");//音樂開關 arrow[i] = loadImage("/graphic/icon/arrow"+i+".png");//上下箭頭 } if(i<4) stage[i] = loadImage("/graphic/stage/stage"+i+".png");//場景 if(i<10) num[i] = loadImage("/graphic/count/"+i+".png");//場景 } Uimg = loadImage("/graphic/icon/up.png");//上 Dimg = loadImage("/graphic/icon/down.png");//下 Simg = loadImage("/graphic/icon/special.png");//特殊 Cimg = loadImage("/graphic/icon/combo.png");//連擊 score = loadImage("/graphic/count/score.png");//分數 time = loadImage("/graphic/count/time.png");//時間 dotImage = loadImage("/graphic/count/dot.png");//冒號 xx = loadImage("/graphic/count/x.png"); home = loadImage("/graphic/button/home.png");//回主畫面 randomcharacter = loadImage("/graphic/button/random.png");//隨機人物 left = loadImage("/graphic/button/left.png");//左箭頭 right = loadImage("/graphic/button/right.png");//右箭頭 gameover = loadImage("/graphic/icon/stop.png");//遊戲結束 endgame = loadImage("/graphic/button/exit.png");//離開遊戲 //設定字型 Font0 = createFont("FFScala", 36);//字型1 Font1 = createFont("FFScala", 18);//字型2 //設定隨機 select = (int) random(19.99);//隨機人物 //載入音樂 minim = new Minim(this); effect0 = minim.loadFile("/sound/effect/0.mp3");//開場音樂 effect1 = minim.loadFile("/sound/effect/1.mp3");//點擊音效 bgm0 = minim.loadFile("/sound/bgm/bgm0.mp3");//背景音樂1 bgm1 = minim.loadFile("/sound/bgm/bgm1.mp3");//背景音樂2 bgm2 = minim.loadFile("/sound/bgm/bgm2.mp3");//背景音樂3 } //顯示畫面 void showtitle(int x){ switch(x){ case 0://開場動畫 image(title[0],0,0);//顯示title0.jpg image(monster[select][m/100%5],596,200);//隨機人物動畫 fill(m/10%255,m/10%255,0);//顏色 textFont(Font0);//字型 text("99160875 Midterm Work",450,400);//閃動文字 effect0.play();//開場音樂 //結束開場 if(m&rt;10000){ nowtitle=1; effect0.close(); } break; case 1://主選單 image(title[1],0,0);//顯示title1.jpg image(button[0][0],440,300);//選單按鈕1 image(button[1][0],440,450);//選單按鈕2 image(endgame,1220,660);//離開遊戲 if(mouseX&rt;440 && mouseX<900){ if(mouseY&rt;300 && mouseY<410) image(button[0][1],440,300);//選單按鈕1 if(mouseY&rt;450 && mouseY<560) image(button[1][1],440,450);//選單按鈕2 } nowscore=0; nowtime=0; break; case 2://人物選擇 image(title[1],0,0);//顯示title1.jpg fill(m/10%255,0,0);//顏色 textFont(Font0);//字型1 text("Select Character",500,220);//閃動文字 //顯示人物 for(int i=0;i<9;i++){ showcharacter(i,10+i*100,300); showcharacter(i+9,60+i*100,450); } image(randomcharacter,1010,310);//隨機人物 break; case 3://場景選擇 image(title[1],0,0);//顯示title1.jpg fill(m/10%255,0,0);//顏色 textFont(Font0);//字型1 text("Select Stage",530,220);//閃動文字 for(int i=0;i<3;i++) showstage(i,80+i*400,290);//顯示場景 break; case 4://遊戲說明 image(title[1],0,0);//顯示title1.jpg image(help[page],320,180);//顯示說明 if(page&rt;0)image(left,130,285);//上頁 if(page<2)image(right,1000,285);//下頁 fill(255,0,0);//顏色 textFont(Font0);//字型1 text((page)+"/2",600,600);//頁數 break; case 5://主畫面 showstage();//遊戲場景 break; case 6://遊戲紀錄 image(title[2],0,0);//顯示title2.jpg fill(0,0,255); textFont(Font0); int a=nowtime/1000; int b=nowtime/1000; text("TIME:"+a+" sec SCORE:"+nowscore,420,360); fill(255,0,0); textFont(Font0); text("BEST TIME:"+(b&rt;a?b:a)+" sec",520,460); text("BEST SCORE:"+(oldscore&rt;nowscore?oldscore:nowscore),470,410); } if(nowtitle&rt;0) showsound(mute,nowbgm);//音樂控制 if(nowtitle&rt;1) image(home,1220,660);//回主畫面 } //顯示場景選擇 void showstage(int x,float y,float z){ image(stage[x],y,z,320,180); image(stage[3],y,z,320,180); if(mouseX&rt;y&&mouseX<y+320&&mouseY&rt;z&&mouseY<z+180){ image(arrow[0],y+135,z-60); image(stage[x],y,z,320,180); } } //遊戲場景 void showstage(){ if(saver==0){ savedtime = millis(); saver++; } if(stageX<-1280) stageX+=1280; image(stage[nowstage],0,0); image(stage[nowstage],stageX+1280,0); strokeWeight(4); image(character[nowcharacter][m/100%5],characterX,characterY); for(int i=0;i<20;i++){ if(monsterX[i]+startX<-100) monsterX[i]+=1280+random(5120); showmonster(i,monsterX[i]+startX); } fill(255,0,0); textFont(Font0); text("VX:"+vx,1000,100); text("VY:"+vy,1000,150); vy-=g; characterY-=vy; if(characterY&rt;=500){ vy=-vy*0.5; vx*=0.9; characterY=500; } if(characterY<-133){ image(arrow[1],characterX,0); textFont(Font1); text("Y:"+abs(characterY),characterX-30,70); } if(abs(vy)<0.1) vy=0; vx*=0.99; if(vx<0.4) vx=0; characterX+=vx; if(characterX&rt;640){ characterX=640; stageX-=vx; startX-=vx; } if(vx&rt;0||abs(vy)&rt;0){ nowscore+=vx/10; int passedtime = millis() - savedtime; nowtime=passedtime; if(nowscore%1000==0){ if(ucount<3) ucount++; if(ucount<3) dcount++; } } else if(characterX!=0&&characterY==500){ image(gameover,0,0); timeover=1; if(oldscore<nowscore){ output = createWriter("/data/score.txt"); output.println(nowscore); output.flush(); // Writes the remaining data to the file output.close(); // Finishes the file } if(oldtime<nowtime){ output2 = createWriter("/data/time.txt"); output2.println(nowtime); output2.flush(); // Writes the remaining data to the file output2.close(); // Finishes the file } } up(); down(); showScore(nowscore); showTime(nowtime/10); } //道具1 void up(){ if(ucount&rt;0&&vy<0) image(item[1][0],10,100); else image(item[1][1],10,100); image(xx,60,100); image(num[ucount],110,100); } //道具2 void down(){ if(dcount&rt;0&&vy&rt;0) image(item[0][0],10,160); else image(item[0][1],10,160); image(xx,60,160); image(num[dcount],110,160); } //顯示人物 void showcharacter(int x,float y,float z){ if(mouseX&rt;y&&mouseX<y+88&&mouseY&rt;z&&mouseY<z+133){ image(arrow[0],y+19,z-50); if(x==11&&keyPressed){ if(key=='r'||key=='R') image(character[18][m/100%5],y,z); }else image(character[x][m/100%5],y,z); }else image(character[x][0],y,z); } //顯示怪物 void showmonster(int x,float y){ image(monster[x][m/100%5],y,500); if(characterX&rt;y&&characterX<y+44&&characterY&rt;433.5&&characterY<566.5){ switch(x){ case 0: combo[0]++; if(combo[0]==3){ combo[0]=0; vx+=50; vy+=100; image(Cimg,50,240); }else{ vx+=5; vy+=5; } break; case 1: combo[1]++; if(combo[1]==3){ combo[1]=0; vx+=100; vy+=50; image(Cimg,50,240); }else{ vx+=10; vy+=5; } break; case 2: combo[0]++; if(combo[0]==3){ combo[0]=0; vx+=50; vy+=100; image(Cimg,50,240); }else{ vx+=5; vy+=10; } break; case 3: combo[2]++; if(combo[2]==3){ combo[2]=0; vx+=100; vy+=100; image(Cimg,50,240); }else{ vx+=10; vy+=10; } break; case 4: combo[2]++; if(combo[2]==3){ combo[2]=0; vx+=100; vy+=100; image(Cimg,50,240); }else{ vx-=5; vy-=5; } break; case 5: combo[0]++; if(combo[0]==3){ combo[0]=0; vx+=50; vy+=100; image(Cimg,50,240); }else{ vx-=10; vy-=5; } break; case 6: combo[0]++; if(combo[0]==3){ combo[0]=0; vx+=50; vy+=100; image(Cimg,50,240); }else{ vx-=5; vy-=10; } break; case 7: combo[1]++; if(combo[1]==3){ combo[1]=0; vx+=100; vy+=50; image(Cimg,50,240); }else{ vx-=10; vy-=10; } break; case 8: combo[0]++; if(combo[0]==3){ combo[0]=0; vx+=50; vy+=100; image(Cimg,50,240); }else{ vx-=5; vy+=10; } break; case 9: combo[1]++; if(combo[1]==3){ combo[1]=0; vx+=100; vy+=50; image(Cimg,50,240); }else{ vx+=10; vy-=5; } break; case 10: combo[2]++; if(combo[2]==3){ combo[2]=0; vx+=100; vy+=100; image(Cimg,50,240); }else vx+=20; break; case 11: combo[1]++; if(combo[1]==3){ combo[1]=0; vx+=100; vy+=50; image(Cimg,50,240); }else vy+=20; break; case 12: combo[0]++; if(combo[0]==3){ combo[0]=0; vx+=50; vy+=100; image(Cimg,50,240); }else vx-=20; break; case 13: combo[1]++; if(combo[1]==3){ combo[1]=0; vx+=100; vy+=50; image(Cimg,50,240); }else vy-=20; break; case 14: combo[1]++; if(combo[1]==3){ combo[1]=0; vx+=100; vy+=50; image(Cimg,50,240); }else{ vx+=5; vy+=5; } break; case 15: combo[0]++; if(combo[0]==3){ combo[0]=0; vx+=50; vy+=100; image(Cimg,50,240); }else{ vx+=5; vy+=5; } break; case 16: combo[1]++; if(combo[1]==3){ combo[1]=0; vx+=100; vy+=50; image(Cimg,50,240); }else{ vx-=5; vy-=5; } break; case 17: if(combo[0]==3){ combo[0]=0; vx+=50; vy+=100; image(Cimg,50,240); }else{ vx-=5; vy-=5; } break; case 18: if(combo[2]==3){ combo[2]=0; vx+=100; vy+=100; image(Cimg,50,240); }else{ vx+=50; vy+=50; image(Simg,50,240); } break; case 19: combo[2]++; if(combo[2]==3){ combo[2]=0; vx+=100; vy+=100; image(Cimg,50,240); }else{ vx=0; vy=0; image(gameover,0,0); timeover=1; }; break; } } } //設定滑鼠拖曳事件 void mouseDragged(){ //準備發射 if(nowtitle==5&&shot==0){ line(44,566,mouseX,mouseY); image(character[nowcharacter][m/100%5],mouseX-44,mouseY-66.5); } } //設定滑鼠釋放事件 void mouseReleased(){ //發射加速 if(nowtitle==5&&shot==0){ vx+=abs(characterX-mouseX-44)/10; vy-=abs(characterY-mouseY+66.5)/10; shot++; } } //設定滑鼠點擊事件 void mouseClicked(){ switch(nowtitle){ case 0://開場動畫 effect0.close(); nowtitle=1; break; case 1://主選單 if(mouseX&rt;440 && mouseX<900){ //選單按鈕1 if(mouseY&rt;300 && mouseY<410){ effect1.play(); image(button[0][2],440,300); nowtitle=2; } //選單按鈕2 if(mouseY&rt;450 && mouseY<560){ effect1.play(); image(button[1][2],440,450); nowtitle=4; } } if(mouseX&rt;1220 && mouseX<1270 && mouseY&rt;660 && mouseY<710){ effect1.play(); exit(); } break; case 2://人物選擇 //第一排 if(mouseY&rt;300 && mouseY<433){ if(mouseX&rt;10 && mouseX<98){ nowcharacter=0; nowtitle=3; effect1.play(); } if(mouseX&rt;110 && mouseX<198){ nowcharacter=1; nowtitle=3; effect1.play(); } if(mouseX&rt;210 && mouseX<298){ nowcharacter=2; nowtitle=3; effect1.play(); } if(mouseX&rt;310 && mouseX<398){ nowcharacter=3; nowtitle=3; effect1.play(); } if(mouseX&rt;410 && mouseX<498){ nowcharacter=4; nowtitle=3; effect1.play(); } if(mouseX&rt;510 && mouseX<598){ nowcharacter=5; nowtitle=3; effect1.play(); } if(mouseX&rt;610 && mouseX<698){ nowcharacter=6; nowtitle=3; effect1.play(); } if(mouseX&rt;710 && mouseX<798){ nowcharacter=7; nowtitle=3; effect1.play(); } if(mouseX&rt;810 && mouseX<898){ nowcharacter=8; nowtitle=3; effect1.play(); } } //第二排 if(mouseY&rt;450&&mouseY<583){ if(mouseX&rt;60 && mouseX<148){ nowcharacter=9; nowtitle=3; effect1.play(); } if(mouseX&rt;160 && mouseX<248){ nowcharacter=10; nowtitle=3; effect1.play(); } if(mouseX&rt;260 && mouseX<348){ if(keyPressed){ if(key=='r'||key=='R') nowcharacter=18; }else nowcharacter=11; nowtitle=3; effect1.play(); } if(mouseX&rt;360 && mouseX<448){ nowcharacter=12; nowtitle=3; effect1.play(); } if(mouseX&rt;460 && mouseX<548){ nowcharacter=13; nowtitle=3; effect1.play(); } if(mouseX&rt;560 && mouseX<648){ nowcharacter=14; nowtitle=3; effect1.play(); } if(mouseX&rt;660 && mouseX<748){ nowcharacter=15; nowtitle=3; effect1.play(); } if(mouseX&rt;760 && mouseX<848){ nowcharacter=16; nowtitle=3; effect1.play(); } if(mouseX&rt;860 && mouseX<948){ nowcharacter=17; nowtitle=3; effect1.play(); } } if(mouseX&rt;1010 && mouseX<1210 && mouseY&rt;310 && mouseY<510){ effect1.play(); nowcharacter=select; nowtitle=3; } break; case 3://場景選擇 if(mouseY&rt;360 && mouseY<540){ if(mouseX&rt;80 && mouseX<400){ effect1.play(); nowtitle=5; nowstage=0; } if(mouseX&rt;480 && mouseX<800){ effect1.play(); nowtitle=5; nowstage=1; } if(mouseX&rt;880 && mouseX<1200){ effect1.play(); nowtitle=5; nowstage=2; } } break; case 4://遊戲說明 if(mouseY&rt;285 && mouseY<435){ if(mouseX&rt;130 && mouseX<280 && page&rt;0){ page--; effect1.play(); } if(mouseX&rt;1000 && mouseX<1150 && page<2){ page++; effect1.play(); } } break; case 5: if(mouseX&rt;10 && mouseX<60 && timeover==0){ if(mouseY&rt;100 && mouseY<150){ if(ucount&rt;0&&vy<0){ vx+=20; vy+=20; ucount--; image(Uimg,50,240); effect1.play(); } } if(mouseY&rt;160 && mouseY<210){ if(dcount&rt;0&&vy&rt;0){ vx+=20; vy-=20; dcount--; image(Dimg,50,240); effect1.play(); } } } break; } if(nowtitle&rt;0){ if(mouseY&rt;660&&mouseY<710){ if(mouseX&rt;10&&mouseX<60){ mute++; effect1.play(); } if(mouseX&rt;70&&mouseX<110){ nowbgm=0; bgm1.pause(); bgm2.pause(); effect1.play(); } if(mouseX&rt;110&&mouseX<150){ nowbgm=1; bgm0.pause(); bgm2.pause(); effect1.play(); } if(mouseX&rt;150&&mouseX<190){ nowbgm=2; bgm0.pause(); bgm1.pause(); effect1.play(); } } } //回主畫面&歸零 if(nowtitle&rt;1){ if(mouseX&rt;1220 && mouseX<1270 && mouseY&rt;660 && mouseY<710){ if(nowtitle!=5) nowtitle=1; else{ nowtitle=6; } mute=1; page=0; shot=0; ucount=3; dcount=3; characterX=0; characterY=500; for(int i=0;i<20;i++) monsterX[i]=monsterX[i]=320+random(5120);//怪物位置 stageX=0;startX=0; vx=0; vy=0; saver=0; effect1.play(); } } } //音樂控制 void showsound(int x,int y){ image(num[1],70,660); image(num[2],110,660); image(num[3],150,660); if(x%2==0){ image(sound[0],10,660); switch(y){ case 0: bgm0.play(); image(playing[0],70,660); break; case 1: bgm1.play(); image(playing[1],110,660); break; case 2: bgm2.play(); image(playing[2],150,660); break; } }else{ image(sound[1],10,660); bgm0.pause(); bgm1.pause(); bgm2.pause(); } } //顯示分數 void showScore(int x){ int a,b,c,d,e,f; f=x%10; x/=10; e=x%10; x/=10; d=x%10; x/=10; c=x%10; x/=10; b=x%10; x/=10; a=x%10; image(score,920,10); image(num[a],1080,10); image(num[b],1110,10); image(num[c],1140,10); image(num[d],1170,10); image(num[e],1200,10); image(num[f],1230,10); } //顯示時間 void showTime(int x){ int a,b,c,d,e,f; f=x%10; x/=10; e=x%10; x/=10; d=x%10; x/=10; c=x%6; x/=6; b=x%10; x/=10; a=x; image(time,10,10); image(num[a],120,10); image(num[b],150,10); image(dotImage,180,10); image(num[c],210,10); image(num[d],240,10); image(dotImage,270,10); image(num[e],300,10); image(num[f],330,10); } void draw(){ try { line = reader.readLine(); } catch (IOException e) { e.printStackTrace(); line = null; } if (line == null) { // Stop reading because of an error or file is empty //noLoop(); } else { oldscore=int(line); } try { line2 = reader2.readLine(); } catch (IOException e) { e.printStackTrace(); line2 = null; } if (line2 == null) { // Stop reading because of an error or file is empty //noLoop(); } else { oldtime=int(line2); } m = millis(); showtitle(nowtitle); }
P.S. 其實在這次成品前,經過多次大行修改,和第8周時完全是兩回事了XD
沒有留言:
張貼留言