ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:17.50KB ,
资源ID:17431747      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/17431747.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(基于java语言的单机版坦克大战源代码Word下载.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

基于java语言的单机版坦克大战源代码Word下载.docx

1、+missiles.size(), 10, 50);explodes count:+explodes.size(), 10, 70);tanks count: +tanks.size(), 10, 90);tanks life:+myTank.getLife(), 10, 110);if(tanks.size() = 0) for(int i=1; i37) this.fire();if(x 10) x = 10;if(y TankWar.GAME_WIDTH-Tank.TANK_WIDTHTankWar.GAME_WIDTH - Tank.TANK_WIDTH - 8;if(y TankWa

2、r.GAME_HEIGHT - Tank.TANK_HEIGHT -8)y = TankWar.GAME_HEIGHT - Tank.TANK_HEIGHT -8;public void keyPressed (KeyEvent e) int key = e.getKeyCode();switch(key) case KeyEvent.VK_F2 :live = true;life = 100;break;case KeyEvent.VK_LEFT :bL = true;case KeyEvent.VK_UP :bU = true;-8)x=break;case KeyEvent.VK_RIG

3、HT :bR = true;case KeyEvent.VK_DOWN :bD = true;changeDir();public void keyReleased (KeyEvent e) case KeyEvent.VK_CONTROL :fire();bL = false;bU = false;bR = false;bD = false;case KeyEvent.VK_A :superFire();public void changeDir() if(bL & !bU &bR &bD) dir = Direction.L;else if(bL & bU &bD) dir = Direc

4、tion.LU;else if(!bL &bD) dir = Direction.U; bR &bD) dir = Direction.RU;bD) dir = Direction.R; bD) dir = Direction.RD; bD) dir = Direction.D; bD) dir = Direction.LD;bD) dir = Direction.STOP;public Missile fire() live) return null;int x = this.x + Tank.TANK_WIDTH/2 - Missile.MISSILE_WIDTH/2;int y = th

5、is.y + Tank.TANK_HEIGHT/2 - Missile.MISSILE_HEIGHT/2;Missile m = new Missile(x, y, ptDir, good, this.tc);tc.missiles.add(m);return m;public Missile fire(Direction dir) Missile m = new Missile(x, y, dir, good, this.tc);private void superFire() Direction dirs = Direction.values();dirs.length-1;/tc.mis

6、siles.add(fire(dirsi);fire(dirsi);public Rectangle getRect() return new Rectangle(x, y, this.TANK_WIDTH, this.TANK_HEIGHT);public boolean collidesWithWall(Wall w) if(this.live & this.getRect().intersects(w.getRect() /this.dir = Direction.STOP;stay();return true;return false;public boolean collidesWi

7、thTank(Tank t) if(this != t) t.live & this.getRect().intersects(t.getRect() this.stay();t.stay();return false;public boolean collidesWithTanks(java.util.List tanks) if(collidesWithTank(t) return true;public void stay() x = oldX;y = oldY;public boolean eat(Blood b) b.isLive() & this.getRect().interse

8、cts(b.getRect() this.life = 100;b.setLive(false);private class BloodBar public void draw(Graphics g) Color c = g.getColor();g.setColor(Color.WHITE);g.drawRect(x, y-20, TANK_WIDTH, 10);int w = TANK_WIDTH * life/100;g.setColor(Color.RED);g.fillRect(x, y-20, w, 10);/*添加子弹的类public class Missile public s

9、tatic final int XSPEED = 20;public static final int YSPEED = 20;public static final int MISSILE_WIDTH = 10;public static final int MISSILE_HEIGHT = 10;private boolean live = true;private boolean good;Tank.Direction dir;private TankWar tw;public Missile(int x, int y, Tank.Direction dir) public Missile(int x, int y, Tank.Direction dir, boolean good, TankWar tw) this(x, y, dir);this.tw = t

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1