資源簡介
用Java編寫的吃豆人小游戲,操作簡單,上下左右控制移動吃豆子,同時會有敵人追趕你,絕對可以運行!!

代碼片段和文件信息
package?eater;
//class?Animation?will?define?the?Eater?as?well?as?the?enemies...be?careful?with?the?
//objects?passed?to?the?constructors..as?unwary?external?modifination?will?cause?problems..
//Finishing?www.codefans.net
//setting?size?and?location?of?an?Animation?object?will?be?responsibility?of?the?
//class?where?this?object?will?be?created...
import?javax.swing.*;
import?java.awt.*;
import?java.util.*;
public?class?Animation?extends?JPanel?implements?GameConstants?{
private?int?direction;
private?int?id;
private?int?velocity;
private?int?oldDirection;
private?boolean?changeImage?=?true;
private?ImageIcon?icons?[];
private?int?[]?imageSequence;
private?int?currentImage?=0;//its?value?can?be?0?to?1?less?thatn?imageSequence.length
//constructor...
public?Animation?(ImageIcon?[]?ic?int?id?int?d){
super(null);
setOpaque(false);
icons?=?ic;
this.id?=?id;
direction?=?d;
setSize(25?25);
}//end?Constructor..
public?int?getID?(){
return?id;
}
public?void?setVelocity?(int?v){
if?(v>=0?&&?v<=MAX_VELOCITY)
velocity?=?v;
}
public?int?getVelocity?(){
return?velocity;
}
public?void?setSequence?(int?[]?newSequence){
imageSequence?=?newSequence;
}
public?int?[]?getSequence?(){
return?imageSequence;
}
public?void?setIcons?(ImageIcon?[]?ic){
icons?=?ic;
}
public?ImageIcon?[]?getIcons?(){
return?icons;
}
public?void?setDirection?(int?d){
if?(direction!=d){
oldDirection?=?direction;
direction?=d;
}
}//end?method?setDirection..
public?int?getOldDirection?(){
return?oldDirection;
}
public?int?getDirection()?{
return?direction;
}
public?void?paintComponent?(Graphics?g){
super.paintComponent(g);
if?(currentImage>=imageSequence.length){
currentImage=0;
}
icons[imageSequence[currentImage]].paintIcon(this?g?0?0);
if?(changeImage)
++currentImage;
changeImage?=?!changeImage;
}
}//end?class?Animation..
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????301??2017-09-05?21:33??eater\.classpath
?????文件????????381??2017-09-05?21:33??eater\.project
?????文件????????598??2017-09-05?21:33??eater\.settings\org.eclipse.jdt.core.prefs
?????文件???????2176??2017-09-05?21:33??eater\bin\eater\Animation.class
?????文件???????1579??2017-09-05?21:33??eater\bin\eater\Background$Dot.class
?????文件????????643??2017-09-05?21:33??eater\bin\eater\Background$Gate.class
?????文件??????13824??2017-09-05?21:33??eater\bin\eater\Background.class
?????文件????????377??2017-09-05?21:33??eater\bin\eater\GameConstants.class
?????文件???????2098??2017-09-05?21:33??eater\bin\eater\GameController.class
?????文件???????3241??2017-09-05?21:33??eater\bin\eater\GameView.class
?????文件?????????22??2017-09-05?21:33??eater\bin\eater\Manifest.txt
?????文件??????14378??2017-09-05?21:33??eater\images\Backup_of_eater.cdr
?????文件????????828??2017-09-05?21:33??eater\images\dot.gif
?????文件??????15774??2017-09-05?21:33??eater\images\eater.cdr
?????文件???????1041??2017-09-05?21:33??eater\images\eater_0_1.gif
?????文件???????1067??2017-09-05?21:33??eater\images\eater_0_2.gif
?????文件???????1063??2017-09-05?21:33??eater\images\eater_0_3.gif
?????文件???????1040??2017-09-05?21:33??eater\images\eater_0_4.gif
?????文件???????1057??2017-09-05?21:33??eater\images\eater_0_5.gif
?????文件???????1057??2017-09-05?21:33??eater\images\eater_0_6.gif
?????文件???????1039??2017-09-05?21:33??eater\images\eater_1_1.gif
?????文件???????1062??2017-09-05?21:33??eater\images\eater_1_2.gif
?????文件???????1057??2017-09-05?21:33??eater\images\eater_1_3.gif
?????文件???????1037??2017-09-05?21:33??eater\images\eater_1_4.gif
?????文件???????1067??2017-09-05?21:33??eater\images\eater_1_5.gif
?????文件???????1062??2017-09-05?21:33??eater\images\eater_1_6.gif
?????文件???????1057??2017-09-05?21:33??eater\images\eater_2_1.gif
?????文件???????1081??2017-09-05?21:33??eater\images\eater_2_2.gif
?????文件???????1083??2017-09-05?21:33??eater\images\eater_2_3.gif
?????文件???????1052??2017-09-05?21:33??eater\images\eater_2_4.gif
............此處省略31個文件信息
評論
共有 條評論