创建敌人的坦克对象E
emyTa
ket
ewE
emyTa
ki1500etsetColor0etsetDirect2启动敌人的坦克
Threadt
ewThreadettstart给敌人坦克添加一颗子弹Shots
ewShotetx10ety302etssaddsThreadt2
ewThreadst2start加入
etsaddet
f
image1ToolkitgetDefaultToolkitgetImagePa
elclassgetResourcequot33jpgquotimage2ToolkitgetDefaultToolkitgetImagePa
elclassgetResourcequot22jpgquotimage3ToolkitgetDefaultToolkitgetImagePa
elclassgetResourcequot11jpgquot
键按下处理a表示左,s表示向下,w表示向上,d表示向右publicvoidkeyPressedKeyEve
teifegetKeyCodeKeyEve
tVK_W设置我的坦克的方向thisherosetDirect0thisheromoveUp
elseifegetKeyCodeKeyEve
tVK_S
fthisherosetDirect2thisheromoveDow
elseifegetKeyCodeKeyEve
tVK_DthisherosetDirect1thisheromoveRight
elseifegetKeyCodeKeyEve
tVK_AthisherosetDirect3thisheromoveLeft
ifegetKeyCodeKeyEve
tVK_JthisheroshotE
emy
f必须重新绘制Pa
elthisrepai
tpublicvoidkeyReleasedKeyEve
te
publicvoidkeyTypedKeyEve
te
classTa
k
设置坦克的速度i
tspeed3publici
tgetSpeed
fretur
speedpublicvoidsetSpeedi
tspeedthisspeedspeed表示坦克的横坐标i
tx0坦克的纵坐标i
ty0i
tdirect0i
tcolor
坦克方向,0表示上,1表示右,2表示下,3表示左publici
tgetColorretur
colorpublicvoidsetColori
tcolor
fthiscolorcolorpublici
tgetDirectretur
direct
publicvoidsetDirecti
tdirectthisdirectdirectpublicTa
ki
txi
tythisxxthisyy
publici
tgetXretur
xpublicvoidsetXi
tx
fthisxxpublici
tgetYretur
ypublicvoidsetYi
tythisyy
classE
emyTa
kexte
dsTa
kimpleme
tsRu
ableboolea
isLivetrue
定义一个向量,可以存放敌人的子弹
VectorltShotgtss
ewVectorltShotgt敌人添加子弹应该在刚刚创建坦克和坦克子弹死亡之后
fpublicE
emyTa
ki
txi
tysuperxy
publicvoidru
whiletrue移动前进switchthisdirectcase0fori
ti0ilti
t100Mathra
domitryThreadsleep50catchExceptio
e
fepri
tStackTraceifygtspeedyspeedbreakcase1fori
ti0ilti
t100Mathra
domitryThreadsleep50catchExceptio
eepri
tStackTraceifxlt400speed30xspeed
fbreakcase2fori
ti0ilti
t100Mathra
domitryThreadsleep50catchExceptio
eepri
tStackTraceifylt300speed30yspeedbreakcase3fori
ti0ilti
t100Mathra
domi
ftryThreadsleep50catchExceptr