首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

基于Java编写的飞机大战小游戏

后端 98.1MB 22 需要积分: 1
立即下载

资源介绍:

基于Java编写的飞机大战小游戏
package com.neutech.base; import com.neutech.runtime.*; import com.neutech.util.Map.DisposeLevel; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; public class GameFrame extends Frame { public GameFrame() { init(); } private void init() { // 设置屏幕的大小 setSize(Constant.WINDOW_OUTER_WIDTH,Constant.WINDOW_OUTER_HEIGHT); // 设置居中 setLocationRelativeTo(null); // 不允许改变屏幕大小 setResizable(false); // 屏蔽输入法 enableInputMethods(false); // 设置显示 setVisible(true); // 启动一个线程定时刷新窗口 new Thread() { public void run(){ while (true) { repaint(); try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } } } }.start(); // 添加一个窗口监听事件,用来实现窗口关闭 addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // 关虚拟机 System.exit(0); } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if(e.getKeyCode()==KeyEvent.VK_SPACE) { Constant.execute=!Constant.execute; } else { plane.keyPressed(e); } } public void keyReleased(KeyEvent e) { plane.keyReleased(e); } }); } // 等级处理 DisposeLevel disposeLevel=new DisposeLevel(); // 上面的地图 Map map1=new Map(-Constant.WINDOW_OUTER_HEIGHT); // 下面的地图 Map map2=new Map(0); // 分数 Score score=new Score(); // 飞机 Plane plane=new Plane(); // 飞机子弹集合 public List planeBulletList =new CopyOnWriteArrayList<>(); // 敌机集合 public List enemyList=new CopyOnWriteArrayList<>(); // 敌机子弹集合 public List enemyBulletList=new CopyOnWriteArrayList<>(); // 爆炸效果集合 public List explodeList=new CopyOnWriteArrayList<>(); // 血条 Blood blood=new Blood(); @Override public void paint(Graphics g) { if(Constant.execute) { map1.move(); map2.move(); map1.draw(g); map2.draw(g); plane.move(); plane.draw(g); plane.fire(); // 遍历飞机的子弹 for (PlaneBullet planeBullet : planeBulletList) { planeBullet.move(); planeBullet.draw(g); } // 遍历敌机 for (Enemy enemy:enemyList) { enemy.move(); enemy.draw(g); enemy.fire(); } // 遍历敌机的子弹 for (EnemyBullet enemyBullet:enemyBulletList) { enemyBullet.move(); enemyBullet.draw(g); } // 分数 score.draw(g); score.create(); // 我方子弹与敌机的碰撞检测 for (PlaneBullet planeBullet : planeBulletList) { for (Enemy enemy:enemyList) { if(planeBullet.creatRectangle().intersects(enemy.creatRectangle())) { // 从集合中清除子弹和敌机 planeBulletList.remove(planeBullet); enemyList.remove(enemy); // 分数+1 score.setNumber(score.getNumber()+1); // 爆炸效果 explodeList.add(new Explode(enemy.getX(),enemy.getY())); } } } // 我方飞机与敌机碰撞检测 for(Enemy enemy:enemyList){ if(plane.creatRectangle().intersects(enemy.creatRectangle())) { // 移除敌机 enemyList.remove(enemy); // 爆炸效果 explodeList.add(new Explode(enemy.getX(),enemy.getY())); // 血条-1 blood.setWidth(blood.getWidth()-20); blood.setX(blood.getX()+20); } } // 遍历爆炸效果 for (Explode explode:explodeList) { explode.draw(g); } // 敌方子弹与我方飞机的碰撞检测 for (EnemyBullet enemyBullet : enemyBulletList) { if(plane.creatRectangle().intersects(enemyBullet.creatRectangle())) { // 移除子弹 enemyBulletList.remove(enemyBullet); // 血条-1 blood.setWidth(blood.getWidth()-20); blood.setX(blood.getX()+20); } } g.setColor(Color.GRAY); g.fillRoundRect(400,40,100,30, 10, 10); blood.draw(g); } } public Image offScreenImage=null; public void update(Graphics g){ if (offScreenImage==null) { offScreenImage=this.createImage(Constant.WINDOW_OUTER_WIDTH,Constant.WINDOW_OUTER_HEIGHT); } Graphics gOff=offScreenImage.getGraphics(); paint(gOff); g.drawImage(offScreenImage,0,0,null); } }

资源文件列表:

plane_wars.zip 大约有120个文件
  1. plane_wars/.gitignore 344B
  2. plane_wars/.idea/
  3. plane_wars/.idea/.gitignore 190B
  4. plane_wars/.idea/compiler.xml 168B
  5. plane_wars/.idea/misc.xml 273B
  6. plane_wars/.idea/modules.xml 267B
  7. plane_wars/.idea/uiDesigner.xml 8.71KB
  8. plane_wars/.idea/workspace.xml 5.07KB
  9. plane_wars/out/
  10. plane_wars/out/production/
  11. plane_wars/out/production/plane_wars/
  12. plane_wars/out/production/plane_wars/com/
  13. plane_wars/out/production/plane_wars/com/neutech/
  14. plane_wars/out/production/plane_wars/com/neutech/base/
  15. plane_wars/out/production/plane_wars/com/neutech/base/Checkpoint.class 1.91KB
  16. plane_wars/out/production/plane_wars/com/neutech/base/Constant.class 658B
  17. plane_wars/out/production/plane_wars/com/neutech/base/Drawable.class 154B
  18. plane_wars/out/production/plane_wars/com/neutech/base/Fire.class 127B
  19. plane_wars/out/production/plane_wars/com/neutech/base/GameFrame$1.class 813B
  20. plane_wars/out/production/plane_wars/com/neutech/base/GameFrame$2.class 718B
  21. plane_wars/out/production/plane_wars/com/neutech/base/GameFrame$3.class 1.01KB
  22. plane_wars/out/production/plane_wars/com/neutech/base/GameFrame.class 4.77KB
  23. plane_wars/out/production/plane_wars/com/neutech/base/Movable.class 133B
  24. plane_wars/out/production/plane_wars/com/neutech/base/Sprite.class 1.29KB
  25. plane_wars/out/production/plane_wars/com/neutech/img/
  26. plane_wars/out/production/plane_wars/com/neutech/img/bullet1.png 4.51KB
  27. plane_wars/out/production/plane_wars/com/neutech/img/bullet2.png 4.66KB
  28. plane_wars/out/production/plane_wars/com/neutech/img/eff1.png 71.96KB
  29. plane_wars/out/production/plane_wars/com/neutech/img/eff2.png 89.03KB
  30. plane_wars/out/production/plane_wars/com/neutech/img/explode1.png 2.58KB
  31. plane_wars/out/production/plane_wars/com/neutech/img/explode2.png 5.78KB
  32. plane_wars/out/production/plane_wars/com/neutech/img/explode3.png 13.13KB
  33. plane_wars/out/production/plane_wars/com/neutech/img/explode4.png 18.46KB
  34. plane_wars/out/production/plane_wars/com/neutech/img/explode5.png 17.88KB
  35. plane_wars/out/production/plane_wars/com/neutech/img/explode6.png 13.14KB
  36. plane_wars/out/production/plane_wars/com/neutech/img/explode7.png 8.03KB
  37. plane_wars/out/production/plane_wars/com/neutech/img/explode8.png 4.64KB
  38. plane_wars/out/production/plane_wars/com/neutech/img/game_over.png 325.32KB
  39. plane_wars/out/production/plane_wars/com/neutech/img/hero.png 18.64KB
  40. plane_wars/out/production/plane_wars/com/neutech/img/img.png 221.33KB
  41. plane_wars/out/production/plane_wars/com/neutech/img/img_bg_level_1.jpg 387.79KB
  42. plane_wars/out/production/plane_wars/com/neutech/img/img_bg_level_2.jpg 189.8KB
  43. plane_wars/out/production/plane_wars/com/neutech/img/img_bg_level_3.jpg 357.93KB
  44. plane_wars/out/production/plane_wars/com/neutech/img/img_bg_level_4.jpg 55.08KB
  45. plane_wars/out/production/plane_wars/com/neutech/img/img_bg_level_5.jpg 74.1KB
  46. plane_wars/out/production/plane_wars/com/neutech/img/img_plane1.png 5.94KB
  47. plane_wars/out/production/plane_wars/com/neutech/img/img_plane2.png 5.95KB
  48. plane_wars/out/production/plane_wars/com/neutech/img/img_plane3.png 5.91KB
  49. plane_wars/out/production/plane_wars/com/neutech/img/img_plane4.png 5.47KB
  50. plane_wars/out/production/plane_wars/com/neutech/music/
  51. plane_wars/out/production/plane_wars/com/neutech/music/bg.wav 50.61MB
  52. plane_wars/out/production/plane_wars/com/neutech/runtime/
  53. plane_wars/out/production/plane_wars/com/neutech/runtime/Blood.class 1.13KB
  54. plane_wars/out/production/plane_wars/com/neutech/runtime/Enemy.class 2.52KB
  55. plane_wars/out/production/plane_wars/com/neutech/runtime/EnemyBullet.class 1.68KB
  56. plane_wars/out/production/plane_wars/com/neutech/runtime/Explode.class 1.89KB
  57. plane_wars/out/production/plane_wars/com/neutech/runtime/GameOver.class 1.08KB
  58. plane_wars/out/production/plane_wars/com/neutech/runtime/Map.class 1.49KB
  59. plane_wars/out/production/plane_wars/com/neutech/runtime/Plane.class 2.64KB
  60. plane_wars/out/production/plane_wars/com/neutech/runtime/PlaneBullet.class 1.66KB
  61. plane_wars/out/production/plane_wars/com/neutech/runtime/Score.class 2.39KB
  62. plane_wars/out/production/plane_wars/com/neutech/start.class 1.25KB
  63. plane_wars/out/production/plane_wars/com/neutech/util/
  64. plane_wars/out/production/plane_wars/com/neutech/util/Map/
  65. plane_wars/out/production/plane_wars/com/neutech/util/Map/DisposeLevel.class 1.18KB
  66. plane_wars/out/production/plane_wars/com/neutech/util/Map/ImageUtils.class 2.29KB
  67. plane_wars/plane_wars.iml 433B
  68. plane_wars/src/
  69. plane_wars/src/com/
  70. plane_wars/src/com/neutech/
  71. plane_wars/src/com/neutech/base/
  72. plane_wars/src/com/neutech/base/Checkpoint.java 1.22KB
  73. plane_wars/src/com/neutech/base/Constant.java 656B
  74. plane_wars/src/com/neutech/base/Drawable.java 124B
  75. plane_wars/src/com/neutech/base/Fire.java 82B
  76. plane_wars/src/com/neutech/base/GameFrame.java 6.02KB
  77. plane_wars/src/com/neutech/base/Movable.java 78B
  78. plane_wars/src/com/neutech/base/Sprite.java 1018B
  79. plane_wars/src/com/neutech/img/
  80. plane_wars/src/com/neutech/img/bullet1.png 4.51KB
  81. plane_wars/src/com/neutech/img/bullet2.png 4.66KB
  82. plane_wars/src/com/neutech/img/eff1.png 71.96KB
  83. plane_wars/src/com/neutech/img/eff2.png 89.03KB
  84. plane_wars/src/com/neutech/img/explode1.png 2.58KB
  85. plane_wars/src/com/neutech/img/explode2.png 5.78KB
  86. plane_wars/src/com/neutech/img/explode3.png 13.13KB
  87. plane_wars/src/com/neutech/img/explode4.png 18.46KB
  88. plane_wars/src/com/neutech/img/explode5.png 17.88KB
  89. plane_wars/src/com/neutech/img/explode6.png 13.14KB
  90. plane_wars/src/com/neutech/img/explode7.png 8.03KB
  91. plane_wars/src/com/neutech/img/explode8.png 4.64KB
  92. plane_wars/src/com/neutech/img/game_over.png 325.32KB
  93. plane_wars/src/com/neutech/img/hero.png 18.64KB
  94. plane_wars/src/com/neutech/img/img.png 221.33KB
  95. plane_wars/src/com/neutech/img/img_bg_level_1.jpg 387.79KB
  96. plane_wars/src/com/neutech/img/img_bg_level_2.jpg 189.8KB
  97. plane_wars/src/com/neutech/img/img_bg_level_3.jpg 357.93KB
  98. plane_wars/src/com/neutech/img/img_bg_level_4.jpg 55.08KB
  99. plane_wars/src/com/neutech/img/img_bg_level_5.jpg 74.1KB
  100. plane_wars/src/com/neutech/img/img_plane1.png 5.94KB
  101. plane_wars/src/com/neutech/img/img_plane2.png 5.95KB
  102. plane_wars/src/com/neutech/img/img_plane3.png 5.91KB
  103. plane_wars/src/com/neutech/img/img_plane4.png 5.47KB
  104. plane_wars/src/com/neutech/music/
  105. plane_wars/src/com/neutech/music/bg.wav 50.61MB
  106. plane_wars/src/com/neutech/runtime/
  107. plane_wars/src/com/neutech/runtime/Blood.java 740B
  108. plane_wars/src/com/neutech/runtime/Enemy.java 1.54KB
  109. plane_wars/src/com/neutech/runtime/EnemyBullet.java 1.17KB
  110. plane_wars/src/com/neutech/runtime/Explode.java 1.14KB
  111. plane_wars/src/com/neutech/runtime/GameOver.java 703B
  112. plane_wars/src/com/neutech/runtime/Map.java 1018B
  113. plane_wars/src/com/neutech/runtime/Plane.java 3.19KB
  114. plane_wars/src/com/neutech/runtime/PlaneBullet.java 1.08KB
  115. plane_wars/src/com/neutech/runtime/Score.java 1.53KB
  116. plane_wars/src/com/neutech/start.java 683B
  117. plane_wars/src/com/neutech/util/
  118. plane_wars/src/com/neutech/util/Map/
  119. plane_wars/src/com/neutech/util/Map/DisposeLevel.java 625B
  120. plane_wars/src/com/neutech/util/Map/ImageUtils.java 1.55KB
0评论
提交 加载更多评论
其他资源 安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL
基于Vue.js和SpringBoot的安康旅游网站,分为管理后台和用户网页端,可以给管理员、游客角色使用,包括景点信息、省市信息、旅游线路、特产管理、购票订单模块和系统基础模块,项目编号T098。 项目录屏:https://www.bilibili.com/video/BV1Hx421y7gn 启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR 项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844
安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL 安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL 安康旅游网站 JAVA+Vue.js+SpringBoot+MySQL
酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL
基于Vue.js和SpringBoot的酒店客房管理系统,分为管理后台和用户网页端,可以给管理员、会员角色使用,包括会员管理、清洁工管理、客房管理、用户预约、用户入住模块和系统基础模块,项目编号T099。 项目录屏:https://www.bilibili.com/video/BV1Kz421Q7m3 启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR 项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844
酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL 酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL 酒店客房管理系统 JAVA+Vue.js+SpringBoot+MySQL
学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL
基于Vue.js和SpringBoot的学生宿舍信息系统,分为管理后台和用户网页端,可以给管理员、学生角色使用,包括宿舍安排、宿舍报修、假期留宿、宿舍缴费模块和系统基础模块,项目编号T100。 项目录屏:https://www.bilibili.com/video/BV1r2421K7pT 启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR 项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844
学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL 学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL 学生宿舍信息系统 JAVA+Vue.js+SpringBoot+MySQL
ManufacturerDatautility.zip
111
追逐台风卡努项目源码及数据集
大家都追逐过春风吧?但有人追逐过台风吗!!!? 今天我就带大家来追逐台风卡努! 什么学校气象学能和清华并列第一?通过气象小项目带大家爱上Python(加强版) 完整内容: -----国际气象网站:ERA5 中关于台风卡努的全球海平面平均气压值的精确的完整数据集 -----项目需要的额外图片(panel图标) -----项目第一部分将生成的全部图片(由于项目较大,生成图片需要大量时间) -----项目两部分对应的完整代码 项目最终结果:生成的完整视频
追逐台风卡努项目源码及数据集
追逐台风卡努项目源码及数据集
基于YOLOv8和WiderPerson的全量数据集的训练文件
基于YOLOv8和WiderPerson的全量数据集的训练文件
中小企业设备管理系统 JAVA+Vue.js+SpringBoot+MySQL
基于Vue.js和SpringBoot的中小企业设备管理系统,分为管理后台和用户网页端,可以给管理员、员工角色使用,包括设备信息、配件信息、配件购买、设备点检、设备润滑、设备改造模块和系统基础模块,项目编号T097。 项目录屏:https://www.bilibili.com/video/BV1Bx421y7Th 启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR 项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844
中小企业设备管理系统 JAVA+Vue.js+SpringBoot+MySQL 中小企业设备管理系统 JAVA+Vue.js+SpringBoot+MySQL 中小企业设备管理系统 JAVA+Vue.js+SpringBoot+MySQL
学生评奖评优管理系统 JAVA+Vue.js+SpringBoot+MySQL
基于Vue.js和SpringBoot的学生评奖评优管理系统,分为管理后台和用户网页端,可以给管理员、教师角色使用,包括院系信息、班级信息、学生成绩、奖学金申请、纪律通报模块和系统基础模块,项目编号T096。 项目录屏:https://www.bilibili.com/video/BV1nZ421a7zR 启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR 项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844
学生评奖评优管理系统 JAVA+Vue.js+SpringBoot+MySQL 学生评奖评优管理系统 JAVA+Vue.js+SpringBoot+MySQL 学生评奖评优管理系统 JAVA+Vue.js+SpringBoot+MySQL