資源簡介
坦克大戰源代碼!!!!非常有參考價值,學習JAVA的朋友可以參考一下!!
代碼片段和文件信息
package?com.goodbaby.encrypt;
import?java.awt.*;
import?javax.swing.*;
import?java.awt.event.*;
import?java.util.EventListener;
public?class?HsTank2?extends?Jframe?{
HsTank2(String?title)?{
this.settitle(title);
this.setSize(608?630);
this.setLocation(300?100);
this.setBackground(Color.WHITE);
MyTank?mp?=?new?MyTank();
this.add(mp);
this.addKeyListener(mp);
new?Thread(mp).start();
}
public?static?void?main(String[]?args)?{
HsTank2?h?=?new?HsTank2(“坦克大戰(版本1.0)“);
h.setVisible(true);
}
}
//?主戰坦克
class?MyTank?extends?JPanel?implements?KeyListener?Runnable?{
int?x?=?280?y?=?280;//?坦克的初始位置
int?op?=?1;//?坦克的移動方向
int?color?=?0;
int?tankspeed?=?8;//?坦克的速度
int?tankbullet?=?8;//?坦克的子彈速度
int?tankfbullet?=?4;//?敵軍的子彈速度
- 上一篇:Android TabHost 標簽在屏幕左側
- 下一篇:jsp開發多媒體博客 論文
評論
共有 條評論