資源簡介
Java寫的吃豆豆游戲(源代碼)Java寫的吃豆豆游戲(源代碼)

代碼片段和文件信息
/**
??*?@(#)fish.BigMouthFish.java??2008-7-31??
??*?Copy?Right?Information :?Tarena
??*?Project :?fish
??*?JDK?version?used :?jdk1.6.4
??*?Comments :?大嘴魚類
??*?Version :?1.0
??*?Sr Date Modified?By Why?&?What?is?modified
??*?1. 2008-7-31? 小豬????? 新建
??**/
package?fish;
import?java.awt.Color;
import?java.awt.Graphics;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?javax.swing.Timer;
?/**
?*?大嘴魚類
?*?此類繼承AcitonListener,實現AcitonPerformed方法,練習ActionListener的另一種實現方法
?*?此類還練習定時器Timer的使用
?*?此類還練習圖形類Graphics的使用
?*?2008-7-31
?*?@author 達內科技[Tarena?Training?Group]
?*?@version 1.0
?*?@since JDK1.6(建議)?
?*/
public?class?BigMouthFish?implements?ActionListener{
/**?大嘴魚嘴的方向:0-上?*/
public?static?int?UP?=?0;
/**?大嘴魚嘴的方向:1-右?*/
public?static?int?RIGHT?=?1;
/**?大嘴魚嘴的方向:2-下?*/
public?static?int?DOWN?=?2;
/**?大嘴魚嘴的方向:3-左?*/
public?static?int?LEFT?=?3;
/**?大嘴魚的身體大小,以size為半徑畫圓?*/
public?int?size?=?50;
/**?大嘴魚現在的方向(以嘴的方向為基準)?*/
public?int?direction?=?RIGHT;
/**?大嘴魚身體的顏色?*/
private?Color?color?=?Color.CYAN;
/**?大嘴魚的位置x?*/
public?int?posx?=?80;
/**?大嘴魚的位置y?*/
public?int?posy?=?80;
/**?大嘴魚的速度,魚每次前進的像素?*/
public?int?speed?=?4;
/**?大嘴魚眼睛的大小?*/
private?int?eyesize?=?size/5;
/**?大嘴魚眼睛的位置x?*/
private?int?eyeposx?=?posx+size/2;
/**?大嘴魚眼睛的位置y?*/
private?int?eyeposy?=?posy+size/5;
/**?大嘴魚眼睛的顏色?*/
private?Color?eyecolor?=?Color.RED;
/**?大嘴魚嘴的最大角度的一半?*/
private?int?maxMonth?=?30;
/**?大嘴魚現在嘴角的角度?*/
private?int?monthsize?=?30;
/**?大嘴魚的嘴是否張開?*/
private?boolean?isOpen?=?true;
private?Timer?time?=?null;
/**
?*?大嘴魚缺省構造函數.
?*?創建一個位置為(200200),大小為50,方向為右,顏色為Color.CYAN,速度為10的大嘴魚
?*/
public?BigMouthFish()?{
//this的使用。
this(20020050RIGHTColor.CYAN4);
}
/**
?*?根據位置、大小、方向、顏色、速度構造一個大嘴魚。
?*?@param?posx?大嘴魚的位置x。
?*?@param?posy?大嘴魚的位置y。
?*?@param?size?大嘴魚的大小。
?*?@param?direction?大嘴魚的方向:0-上;1-右;2-下;3-左。出入錯誤時,默認改為1。
?*?@param?color?大嘴魚的顏色。
?*?@param?speed?大嘴魚的速度。
?*/
public?BigMouthFish(int?posxint?posyint?sizeint?directionColor?colorint?speed)?{
this.posx?=?posx;
this.posy?=?posy;
this.size?=?size;
if(direction==1?||?direction==2?||?direction==3?||?direction==4)
this.direction?=?direction;
this.color?=?color;
this.speed?=?speed;
eyesize?=?size/7;
initEye();
time?=?new?Timer(FishPool.reTimethis);
time.start();
}?
/**
?*?大嘴魚移動。根據魚的方向移動魚。
?*/
public?void?move(){
switch?(direction)?{
case?0:
posy--;
break;
case?1:
posx++;
break;
case?2:
posy++;
break;
case?3:
posx--;
break;
default:
break;
}
}
/**
?*?改變大嘴魚身體的顏色。
?*?@param?color?欲改變大嘴魚身體的顏色
?*/
public?void?changeColor(Color?color){
this.color?=?color;
}
/**
?*?改變大嘴魚的方向
?*?@param?direction?欲改變大嘴魚的方向
?*/
public?void?changeDir(int?direction){
this.direction?=?direction;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????14630??2008-08-14?09:51??吃豆豆\BigFish.jar
?????文件?????128000??2008-10-12?17:25??吃豆豆\吃豆豆.doc
?????文件???????5041??2008-08-04?09:26??吃豆豆\源代碼\src\fish\BigMouthFish.java
?????文件???????2976??2008-10-12?14:53??吃豆豆\源代碼\src\fish\FishBean.java
?????文件???????8654??2008-08-05?10:19??吃豆豆\源代碼\src\fish\FishPool.java
?????文件???????3070??2008-08-04?09:27??吃豆豆\源代碼\src\main\BigMouthFishfr
?????文件???????1105??2008-09-27?17:15??吃豆豆\源代碼\src\tools\FishUtilities.java
?????文件???????1127??2008-07-31?21:58??吃豆豆\源代碼\src\tools\RandomUtil.java
?????文件???????1273??2009-05-16?10:15??吃豆豆\說明文檔\doc\allclasses-fr
?????文件???????1153??2009-05-16?10:15??吃豆豆\說明文檔\doc\allclasses-nofr
?????文件???????5276??2009-05-16?10:15??吃豆豆\說明文檔\doc\constant-values.html
?????文件???????5241??2009-05-16?10:15??吃豆豆\說明文檔\doc\deprecated-list.html
?????文件??????24471??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\BigMouthFish.html
?????文件???????8665??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\class-use\BigMouthFish.html
?????文件???????8581??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\class-use\FishBean.html
?????文件???????5828??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\class-use\FishPool.DownListenerImpl.html
?????文件???????7165??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\class-use\FishPool.html
?????文件???????5828??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\class-use\FishPool.LeftListenerImpl.html
?????文件???????5838??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\class-use\FishPool.RightListenerImpl.html
?????文件???????5838??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\class-use\FishPool.TimerListenerImpl.html
?????文件???????5808??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\class-use\FishPool.UpListenerImpl.html
?????文件??????19713??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\FishBean.html
?????文件??????12503??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\FishPool.DownListenerImpl.html
?????文件??????35963??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\FishPool.html
?????文件??????12539??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\FishPool.LeftListenerImpl.html
?????文件??????12557??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\FishPool.RightListenerImpl.html
?????文件??????10644??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\FishPool.TimerListenerImpl.html
?????文件??????12343??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\FishPool.UpListenerImpl.html
?????文件???????1062??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\package-fr
?????文件???????6411??2009-05-16?10:15??吃豆豆\說明文檔\doc\fish\package-summary.html
............此處省略62個文件信息
- 上一篇:Java寫的畫圖程序
- 下一篇:JAVA修改AD域密碼_免證書
評論
共有 條評論