• 大小: 59KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: Java
  • 标签: Java  

资源简介

用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个文件信息

评论

共有 条评论