分析

  1. 飞机大战 首先对这个游戏分析,在屏幕上的物体都是飞行物,我们可以把建一个类,让其他飞行物继承这个类.游戏中应有英雄机(也就是自己控制的飞机)、敌人。而敌人应该分为打死给分的飞机(就是普通飞机),另一种就是打死有奖励的敌人。他们都应该是飞行物的子类,我们也可以为普通飞机和给奖励的敌人设一个接口让他们去实现接口,这样有利于以后的扩展,我在这里给的简化版的飞机大战,主要是为了让大家了解面向对象。

第一步建立飞行物类


  1. import java.awt.image.BufferedImage;
  2. /**
  3. * 飞行物(敌机,蜜蜂,子弹,英雄机)
  4. */
  5. public abstract class FlyingObject {
  6. protected int x; //x坐标
  7. protected int y; //y坐标
  8. protected int width; //宽
  9. protected int height; //高
  10. protected BufferedImage image; //图片
  11. public int getX() {
  12. return x;
  13. }
  14. public void setX(int x) {
  15. this.x = x;
  16. }
  17. public int getY() {
  18. return y;
  19. }
  20. public void setY(int y) {
  21. this.y = y;
  22. }
  23. public int getWidth() {
  24. return width;
  25. }
  26. public void setWidth(int width) {
  27. this.width = width;
  28. }
  29. public int getHeight() {
  30. return height;
  31. }
  32. public void setHeight(int height) {
  33. this.height = height;
  34. }
  35. public BufferedImage getImage() {
  36. return image;
  37. }
  38. public void setImage(BufferedImage image) {
  39. this.image = image;
  40. }
  41. /**
  42. * 检查是否出界
  43. * @return true 出界与否
  44. */
  45. public abstract boolean outOfBounds();
  46. /**
  47. * 飞行物移动一步
  48. */
  49. public abstract void step();
  50. /**
  51. * 检查当前飞行物体是否被子弹(x,y)击(shoot)中
  52. * @param Bullet 子弹对象
  53. * @return true表示被击中了
  54. */
  55. public boolean shootBy(Bullet bullet){
  56. int x = bullet.x; //子弹横坐标
  57. int y = bullet.y; //子弹纵坐标
  58. return this.x<x && x<this.x+width && this.y<y && y<this.y+height;
  59. }
  60. }

第二步创建英雄级类

  1. import java.awt.image.BufferedImage;
  2. /**
  3. * 英雄机:是飞行物
  4. */
  5. public class Hero extends FlyingObject{
  6. private BufferedImage[] images = {}; //英雄机图片
  7. private int index = 0; //英雄机图片切换索引
  8. private int doubleFire; //双倍火力
  9. private int life; //命
  10. /** 初始化数据 */
  11. public Hero(){
  12. life = 3; //初始3条命
  13. doubleFire = 0; //初始火力为0
  14. images = new BufferedImage[]{ShootGame.hero0, ShootGame.hero1}; //英雄机图片数组
  15. image = ShootGame.hero0; //初始为hero0图片
  16. width = image.getWidth();
  17. height = image.getHeight();
  18. x = 150;
  19. y = 400;
  20. }
  21. /** 获取双倍火力 */
  22. public int isDoubleFire() {
  23. return doubleFire;
  24. }
  25. /** 设置双倍火力 */
  26. public void setDoubleFire(int doubleFire) {
  27. this.doubleFire = doubleFire;
  28. }
  29. /** 增加火力 */
  30. public void addDoubleFire(){
  31. doubleFire = 40;
  32. }
  33. /** 增命 */
  34. public void addLife(){ //增命
  35. life++;
  36. }
  37. /** 减命 */
  38. public void subtractLife(){ //减命
  39. life--;
  40. }
  41. /** 获取命 */
  42. public int getLife(){
  43. return life;
  44. }
  45. /** 当前物体移动了一下,相对距离,x,y鼠标位置 */
  46. public void moveTo(int x,int y){
  47. this.x = x - width/2;
  48. this.y = y - height/2;
  49. }
  50. /** 越界处理 */
  51. @Override
  52. public boolean outOfBounds() {
  53. return false;
  54. }
  55. /** 发射子弹 */
  56. public Bullet[] shoot(){
  57. int xStep = width/4; //4半
  58. int yStep = 20; //步
  59. if(doubleFire>0){ //双倍火力
  60. Bullet[] bullets = new Bullet[2];
  61. bullets[0] = new Bullet(x+xStep,y-yStep); //y-yStep(子弹距飞机的位置)
  62. bullets[1] = new Bullet(x+3*xStep,y-yStep);
  63. return bullets;
  64. }else{ //单倍火力
  65. Bullet[] bullets = new Bullet[1];
  66. bullets[0] = new Bullet(x+2*xStep,y-yStep);
  67. return bullets;
  68. }
  69. }
  70. /** 移动 */
  71. @Override
  72. public void step() {
  73. if(images.length>0){
  74. image = images[index++/10%images.length]; //切换图片hero0hero1
  75. }
  76. }
  77. /** 碰撞算法 */
  78. public boolean hit(FlyingObject other){
  79. int x1 = other.x - this.width/2; //x坐标最小距离
  80. int x2 = other.x + this.width/2 + other.width; //x坐标最大距离
  81. int y1 = other.y - this.height/2; //y坐标最小距离
  82. int y2 = other.y + this.height/2 + other.height; //y坐标最大距离
  83. int herox = this.x + this.width/2; //英雄机x坐标中心点距离
  84. int heroy = this.y + this.height/2; //英雄机y坐标中心点距离
  85. return herox>x1 && herox<x2 && heroy>y1 && heroy<y2; //区间范围内为撞上了
  86. }
  87. }

第三步:建立敌人接口(普通敌人)

  1. /**
  2. * 敌人,可以有分数
  3. */
  4. public interface Enemy {
  5. /** 敌人的分数 */
  6. int getScore();
  7. }

第四步建立给奖励的敌人接口(就是特殊的敌人)

  1. /**
  2. * 奖励
  3. */
  4. public interface Award {
  5. int DOUBLE_FIRE = 0; //双倍火力
  6. int LIFE = 1; //1条命
  7. /** 获得奖励类型(上面的0或1) */
  8. int getType();
  9. }

第五步:普通敌人对象


  1. import java.util.Random;
  2. /**
  3. * 敌飞机: 是飞行物,也是敌人
  4. */
  5. public class Airplane extends FlyingObject implements Enemy {
  6. private int speed = 3; //移动步骤
  7. /** 初始化数据 */
  8. public Airplane(){
  9. this.image = ShootGame.airplane;
  10. width = image.getWidth();
  11. height = image.getHeight();
  12. y = -height;
  13. Random rand = new Random();
  14. x = rand.nextInt(ShootGame.WIDTH - width);
  15. }
  16. /** 获取分数 */
  17. @Override
  18. public int getScore() {
  19. return 5;
  20. }
  21. /** //越界处理 */
  22. @Override
  23. public boolean outOfBounds() {
  24. return y>ShootGame.HEIGHT;
  25. }
  26. /** 移动 */
  27. @Override
  28. public void step() {
  29. y += speed;
  30. }
  31. }

第六步 特殊敌人(有奖励特殊的敌人)


  1. import java.util.Random;
  2. /** 蜜蜂 */
  3. public class Bee extends FlyingObject implements Award{
  4. private int xSpeed = 1; //x坐标移动速度
  5. private int ySpeed = 2; //y坐标移动速度
  6. private int awardType; //奖励类型
  7. /** 初始化数据 */
  8. public Bee(){
  9. this.image = ShootGame.bee;
  10. width = image.getWidth();
  11. height = image.getHeight();
  12. y = -height;
  13. Random rand = new Random();
  14. x = rand.nextInt(ShootGame.WIDTH - width);
  15. awardType = rand.nextInt(2); //初始化时给奖励
  16. }
  17. /** 获得奖励类型 */
  18. public int getType(){
  19. return awardType;
  20. }
  21. /** 越界处理 */
  22. @Override
  23. public boolean outOfBounds() {
  24. return y>ShootGame.HEIGHT;
  25. }
  26. /** 移动,可斜着飞 */
  27. @Override
  28. public void step() {
  29. x += xSpeed;
  30. y += ySpeed;
  31. if(x > ShootGame.WIDTH-width){
  32. xSpeed = -1;
  33. }
  34. if(x < 0){
  35. xSpeed = 1;
  36. }
  37. }
  38. }

第七步 子弹类的建立(子弹也是飞行物)


  1. /**
  2. * 子弹类:是飞行物
  3. */
  4. public class Bullet extends FlyingObject {
  5. private int speed = 3; //移动的速度
  6. /** 初始化数据 */
  7. public Bullet(int x,int y){
  8. this.x = x;
  9. this.y = y;
  10. this.image = ShootGame.bullet;
  11. }
  12. /** 移动 */
  13. @Override
  14. public void step(){
  15. y-=speed;
  16. }
  17. /** 越界处理 */
  18. @Override
  19. public boolean outOfBounds() {
  20. return y<-height;
  21. }
  22. }

最后一部分

我们的主类来了,我们的准备工作就完了

激动的时刻来了


  1. import java.awt.Font;
  2. import java.awt.Color;
  3. import java.awt.Graphics;
  4. import java.awt.event.MouseAdapter;
  5. import java.awt.event.MouseEvent;
  6. import java.util.Arrays;
  7. import java.util.Random;
  8. import java.util.Timer;
  9. import java.util.TimerTask;
  10. import java.awt.image.BufferedImage;
  11. import javax.imageio.ImageIO;
  12. import javax.swing.ImageIcon;
  13. import javax.swing.JFrame;
  14. import javax.swing.JPanel;
  15. public class ShootGame extends JPanel {
  16. public static void main(String[] args) {
  17. JFrame frame = new JFrame("Fly");
  18. ShootGame game = new ShootGame(); // 面板对象
  19. frame.add(game); // 将面板添加到JFrame中
  20. frame.setSize(WIDTH, HEIGHT); // 设置大小
  21. frame.setAlwaysOnTop(true); // 设置其总在最上
  22. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 默认关闭操作
  23. frame.setIconImage(new ImageIcon("images/icon.jpg").getImage()); // 设置窗体的图标
  24. frame.setLocationRelativeTo(null); // 设置窗体初始位置
  25. frame.setVisible(true); // 尽快调用paint
  26. game.action(); // 启动执行
  27. }
  28. public static final int WIDTH = 400; // 面板宽
  29. public static final int HEIGHT = 654; // 面板高
  30. /** 游戏的当前状态: START RUNNING PAUSE GAME_OVER */
  31. private int state;
  32. private static final int START = 0;
  33. private static final int RUNNING = 1;
  34. private static final int PAUSE = 2;
  35. private static final int GAME_OVER = 3;
  36. private int score = 0; // 得分
  37. private Timer timer; // 定时器
  38. private int intervel = 1000 / 100; // 时间间隔(毫秒)
  39. public static BufferedImage background;
  40. public static BufferedImage start;
  41. public static BufferedImage airplane;
  42. public static BufferedImage bee;
  43. public static BufferedImage bullet;
  44. public static BufferedImage hero0;
  45. public static BufferedImage hero1;
  46. public static BufferedImage pause;
  47. public static BufferedImage gameover;
  48. private FlyingObject[] flyings = {}; // 敌机数组
  49. private Bullet[] bullets = {}; // 子弹数组
  50. private Hero hero = new Hero(); // 英雄机
  51. static { // 静态代码块,初始化图片资源
  52. try {
  53. background = ImageIO.read(ShootGame.class
  54. .getResource("background.png"));
  55. start = ImageIO.read(ShootGame.class.getResource("start.png"));
  56. airplane = ImageIO
  57. .read(ShootGame.class.getResource("airplane.png"));
  58. bee = ImageIO.read(ShootGame.class.getResource("bee.png"));
  59. bullet = ImageIO.read(ShootGame.class.getResource("bullet.png"));
  60. hero0 = ImageIO.read(ShootGame.class.getResource("hero0.png"));
  61. hero1 = ImageIO.read(ShootGame.class.getResource("hero1.png"));
  62. pause = ImageIO.read(ShootGame.class.getResource("pause.png"));
  63. gameover = ImageIO
  64. .read(ShootGame.class.getResource("gameover.png"));
  65. } catch (Exception e) {
  66. e.printStackTrace();
  67. }
  68. }
  69. /** 画 */
  70. @Override
  71. public void paint(Graphics g) {
  72. g.drawImage(background, 0, 0, null); // 画背景图
  73. paintHero(g); // 画英雄机
  74. paintBullets(g); // 画子弹
  75. paintFlyingObjects(g); // 画飞行物
  76. paintScore(g); // 画分数
  77. paintState(g); // 画游戏状态
  78. }
  79. /** 画英雄机 */
  80. public void paintHero(Graphics g) {
  81. g.drawImage(hero.getImage(), hero.getX(), hero.getY(), null);
  82. }
  83. /** 画子弹 */
  84. public void paintBullets(Graphics g) {
  85. for (int i = 0; i < bullets.length; i++) {
  86. Bullet b = bullets[i];
  87. g.drawImage(b.getImage(), b.getX() - b.getWidth() / 2, b.getY(),
  88. null);
  89. }
  90. }
  91. /** 画飞行物 */
  92. public void paintFlyingObjects(Graphics g) {
  93. for (int i = 0; i < flyings.length; i++) {
  94. FlyingObject f = flyings[i];
  95. g.drawImage(f.getImage(), f.getX(), f.getY(), null);
  96. }
  97. }
  98. /** 画分数 */
  99. public void paintScore(Graphics g) {
  100. int x = 10; // x坐标
  101. int y = 25; // y坐标
  102. Font font = new Font(Font.SANS_SERIF, Font.BOLD, 14); // 字体
  103. g.setColor(new Color(0x3A3B3B));
  104. g.setFont(font); // 设置字体
  105. g.drawString("SCORE:" + score, x, y); // 画分数
  106. y += 20; // y坐标增20
  107. g.drawString("LIFE:" + hero.getLife(), x, y); // 画命
  108. }
  109. /** 画游戏状态 */
  110. public void paintState(Graphics g) {
  111. switch (state) {
  112. case START: // 启动状态
  113. g.drawImage(start, 0, 0, null);
  114. break;
  115. case PAUSE: // 暂停状态
  116. g.drawImage(pause, 0, 0, null);
  117. break;
  118. case GAME_OVER: // 游戏终止状态
  119. g.drawImage(gameover, 0, 0, null);
  120. break;
  121. }
  122. }
  123. /** 启动执行代码 */
  124. public void action() {
  125. // 鼠标监听事件
  126. MouseAdapter l = new MouseAdapter() {
  127. @Override
  128. public void mouseMoved(MouseEvent e) { // 鼠标移动
  129. if (state == RUNNING) { // 运行状态下移动英雄机--随鼠标位置
  130. int x = e.getX();
  131. int y = e.getY();
  132. hero.moveTo(x, y);
  133. }
  134. }
  135. @Override
  136. public void mouseEntered(MouseEvent e) { // 鼠标进入
  137. if (state == PAUSE) { // 暂停状态下运行
  138. state = RUNNING;
  139. }
  140. }
  141. @Override
  142. public void mouseExited(MouseEvent e) { // 鼠标退出
  143. if (state != GAME_OVER&&state!=START) { // 游戏未结束,则设置其为暂停
  144. state = PAUSE;
  145. }
  146. }
  147. @Override
  148. public void mouseClicked(MouseEvent e) { // 鼠标点击
  149. switch (state) {
  150. case START:
  151. state = RUNNING; // 启动状态下运行
  152. break;
  153. case GAME_OVER: // 游戏结束,清理现场
  154. flyings = new FlyingObject[0]; // 清空飞行物
  155. bullets = new Bullet[0]; // 清空子弹
  156. hero = new Hero(); // 重新创建英雄机
  157. score = 0; // 清空成绩
  158. state = START; // 状态设置为启动
  159. break;
  160. }
  161. }
  162. };
  163. this.addMouseListener(l); // 处理鼠标点击操作
  164. this.addMouseMotionListener(l); // 处理鼠标滑动操作
  165. timer = new Timer(); // 主流程控制
  166. timer.schedule(new TimerTask() {
  167. @Override
  168. public void run() {
  169. if (state == RUNNING) { // 运行状态
  170. enterAction(); // 飞行物入场
  171. stepAction(); // 走一步
  172. shootAction(); // 英雄机射击
  173. bangAction(); // 子弹打飞行物
  174. outOfBoundsAction(); // 删除越界飞行物及子弹
  175. checkGameOverAction(); // 检查游戏结束
  176. }
  177. repaint(); // 重绘,调用paint()方法
  178. }
  179. }, intervel, intervel);
  180. }
  181. int flyEnteredIndex = 0; // 飞行物入场计数
  182. /** 飞行物入场 */
  183. public void enterAction() {
  184. flyEnteredIndex++;
  185. if (flyEnteredIndex % 40 == 0) { // 400毫秒生成一个飞行物--10*40
  186. FlyingObject obj = nextOne(); // 随机生成一个飞行物
  187. flyings = Arrays.copyOf(flyings, flyings.length + 1);
  188. flyings[flyings.length - 1] = obj;
  189. }
  190. }
  191. /** 走一步 */
  192. public void stepAction() {
  193. for (int i = 0; i < flyings.length; i++) { // 飞行物走一步
  194. FlyingObject f = flyings[i];
  195. f.step();
  196. }
  197. for (int i = 0; i < bullets.length; i++) { // 子弹走一步
  198. Bullet b = bullets[i];
  199. b.step();
  200. }
  201. hero.step(); // 英雄机走一步
  202. }
  203. /** 飞行物走一步 */
  204. public void flyingStepAction() {
  205. for (int i = 0; i < flyings.length; i++) {
  206. FlyingObject f = flyings[i];
  207. f.step();
  208. }
  209. }
  210. int shootIndex = 0; // 射击计数
  211. /** 射击 */
  212. public void shootAction() {
  213. shootIndex++;
  214. if (shootIndex % 30 == 0) { // 300毫秒发一颗
  215. Bullet[] bs = hero.shoot(); // 英雄打出子弹
  216. bullets = Arrays.copyOf(bullets, bullets.length + bs.length); // 扩容
  217. System.arraycopy(bs, 0, bullets, bullets.length - bs.length,
  218. bs.length); // 追加数组
  219. }
  220. }
  221. /** 子弹与飞行物碰撞检测 */
  222. public void bangAction() {
  223. for (int i = 0; i < bullets.length; i++) { // 遍历所有子弹
  224. Bullet b = bullets[i];
  225. bang(b); // 子弹和飞行物之间的碰撞检查
  226. }
  227. }
  228. /** 删除越界飞行物及子弹 */
  229. public void outOfBoundsAction() {
  230. int index = 0; // 索引
  231. FlyingObject[] flyingLives = new FlyingObject[flyings.length]; // 活着的飞行物
  232. for (int i = 0; i < flyings.length; i++) {
  233. FlyingObject f = flyings[i];
  234. if (!f.outOfBounds()) {
  235. flyingLives[index++] = f; // 不越界的留着
  236. }
  237. }
  238. flyings = Arrays.copyOf(flyingLives, index); // 将不越界的飞行物都留着
  239. index = 0; // 索引重置为0
  240. Bullet[] bulletLives = new Bullet[bullets.length];
  241. for (int i = 0; i < bullets.length; i++) {
  242. Bullet b = bullets[i];
  243. if (!b.outOfBounds()) {
  244. bulletLives[index++] = b;
  245. }
  246. }
  247. bullets = Arrays.copyOf(bulletLives, index); // 将不越界的子弹留着
  248. }
  249. /** 检查游戏结束 */
  250. public void checkGameOverAction() {
  251. if (isGameOver()) {
  252. state = GAME_OVER; // 改变状态
  253. }
  254. }
  255. /** 检查游戏是否结束 */
  256. public boolean isGameOver() {
  257. for (int i = 0; i < flyings.length; i++) {
  258. int index = -1;
  259. FlyingObject obj = flyings[i];
  260. if (hero.hit(obj)) { // 检查英雄机与飞行物是否碰撞
  261. hero.subtractLife(); // 减命
  262. hero.setDoubleFire(0); // 双倍火力解除
  263. index = i; // 记录碰上的飞行物索引
  264. }
  265. if (index != -1) {
  266. FlyingObject t = flyings[index];
  267. flyings[index] = flyings[flyings.length - 1];
  268. flyings[flyings.length - 1] = t; // 碰上的与最后一个飞行物交换
  269. flyings = Arrays.copyOf(flyings, flyings.length - 1); // 删除碰上的飞行物
  270. }
  271. }
  272. return hero.getLife() <= 0;
  273. }
  274. /** 子弹和飞行物之间的碰撞检查 */
  275. public void bang(Bullet bullet) {
  276. int index = -1; // 击中的飞行物索引
  277. for (int i = 0; i < flyings.length; i++) {
  278. FlyingObject obj = flyings[i];
  279. if (obj.shootBy(bullet)) { // 判断是否击中
  280. index = i; // 记录被击中的飞行物的索引
  281. break;
  282. }
  283. }
  284. if (index != -1) { // 有击中的飞行物
  285. FlyingObject one = flyings[index]; // 记录被击中的飞行物
  286. FlyingObject temp = flyings[index]; // 被击中的飞行物与最后一个飞行物交换
  287. flyings[index] = flyings[flyings.length - 1];
  288. flyings[flyings.length - 1] = temp;
  289. flyings = Arrays.copyOf(flyings, flyings.length - 1); // 删除最后一个飞行物(即被击中的)
  290. // 检查one的类型(敌人加分,奖励获取)
  291. if (one instanceof Enemy) { // 检查类型,是敌人,则加分
  292. Enemy e = (Enemy) one; // 强制类型转换
  293. score += e.getScore(); // 加分
  294. } else if (one instanceof Award) { // 若为奖励,设置奖励
  295. Award a = (Award) one;
  296. int type = a.getType(); // 获取奖励类型
  297. switch (type) {
  298. case Award.DOUBLE_FIRE:
  299. hero.addDoubleFire(); // 设置双倍火力
  300. break;
  301. case Award.LIFE:
  302. hero.addLife(); // 设置加命
  303. break;
  304. }
  305. }
  306. }
  307. }
  308. /**
  309. * 随机生成飞行物
  310. *
  311. * @return 飞行物对象
  312. */
  313. public static FlyingObject nextOne() {
  314. Random random = new Random();
  315. int type = random.nextInt(20); // [0,20)
  316. if (type == 0) {
  317. return new Bee();
  318. } else {
  319. return new Airplane();
  320. }
  321. }
  322. }

游戏到这里就结束了这里有几张图片游戏中用到的图片,大家也可以自己找些自己喜欢的图片去用

hero1.png

hero0.png

start.png

gameover.png

pause.png

bee.png

airplane.png

java版飞机大战 实战项目详细步骤.md的更多相关文章

  1. java版飞机大战代码

    @ 目录 前言 Plane PlaneStatus类 Power类 Gift Diji play类 over类 MainFrame主类 MyZiDan DijiZiDan Before 前言 很久之前 ...

  2. 用grunt搭建自动化的web前端开发环境实战教程(详细步骤)

    用grunt搭建自动化的web前端开发环境实战教程(详细步骤) jQuery在使用grunt,bootstrap在使用grunt,百度UEditor在使用grunt,你没有理由不学.不用!前端自动化, ...

  3. 微信5.0 Android版飞机大战破解无敌模式手记

    微信5.0 Android版飞机大战破解无敌模式手记 转载: http://www.blogjava.net/zh-weir/archive/2013/08/14/402821.html 微信5.0 ...

  4. Python版飞机大战

    前面学了java用java写了飞机大战这次学完python基础后写了个python版的飞机大战,有兴趣的可以看下. 父类是飞行物类是所有对象的父类,setting里面是需要加载的图片,你可以换称自己的 ...

  5. Java实现飞机大战游戏

    飞机大战详细文档 文末有源代码,以及本游戏使用的所有素材,将plane2文件复制在src文件下可以直接运行. 实现效果: 结构设计 角色设计 飞行对象类 FlyObject 战机类 我的飞机 MyPl ...

  6. python版飞机大战代码简易版

    # -*- coding:utf-8 -*- import pygame import sys from pygame.locals import * from pygame.font import ...

  7. 【 java版坦克大战--事件处理】 坦克动起来了

    折腾了这么久,坦克总算能动了.只贴代码编辑不给上首页,花了半个小时的时间写了n多注释. 再顺便把绘图的原理发在这里: 绘图原理 Component类提供了两个和绘图有关的重要方法: ①   paint ...

  8. maven(3)------maven构建web项目详细步骤

    eclipse集成工具,轻松通过maven构建web项目步骤如下: 一, 右键,new -->project, 进入下一页面 二,选择"Maven Project", 点击下 ...

  9. 【 java版坦克大战--绘图技术】 绘制坦克

    通过上一节,我们学会的用java绘图.那现在就用java绘制自己坦克. 首先通过分析坦克由这几部分组成.如图 各个部件的长宽如图.15,10为圆心. /** * 坦克游戏的1.0版 * 1.画出坦克 ...

随机推荐

  1. hibernate总结-持续更新

    简介 hibernate官网:Hibernate Hibernate 是一个开放源代码的对象关系映射框架,它对 JDBC 进行了非常轻量级的对象封装,使得 Java 程序员可以随心所欲的使用对象编程思 ...

  2. 从零Wordpress建站经验分享,内附耗时间及成本

    5月末回国,工作进入空档期. 每天上班没有任务压身,日子过得反而更加难熬. 一直自己做一个网站,却总下不定决心,总是懒得迈出第一步. 正巧朋友需要建设一个宣传用网站. 外面的公司给他报价很高. 反正我 ...

  3. java基础系列--Exception异常处理

    原创作品,可以转载,但是请标注出处地址:http://www.cnblogs.com/V1haoge/p/7191280.html 1.概述 Java代码中的异常处理是非常重要的一环,从代码中可以看到 ...

  4. pc端的企业网站(IT修真院test8)详解1-1

    这任务需求我们使用推特的前端框架bootstrap来实现.先放psd图. 上传这些图片也蛮大的.为此我使用office picture manager压缩了图片. 方法:alt+p+o,然后tab+下 ...

  5. 事务之使用JDBC进行事务的操作2

    本篇将讲诉如何使用JDBC进行数据库有关事务的操作.在上一篇博客中已经介绍了事务的概念,和在MySQL命令行窗口进行开启事务,提交事务以及回滚事务的操作. 似乎事务和批处理都可以一次同时执行多条SQL ...

  6. Android 上层应用读写设备节点

    Android 上层应用读写设备节点 Android L [TOC] 1. Android 设备节点 Android基于Linux内核.设备节点文件是设备驱动的逻辑文件,可以通过设备节点来访问设备驱动 ...

  7. 构建 MariaDB Galera Cluster 分布式数据库集群(一)

    MariaDB Galera Cluster 介绍 简介 MariaDB集群是MariaDB同步多主机集群,仅支持XtraDB(详见本文结尾注释)/InnoDB存储引擎(虽然有对MyISAM实验支持 ...

  8. 53. leetcode557. Reverse Words in a String III

    557. Reverse Words in a String III Given a string, you need to reverse the order of characters in ea ...

  9. cacti监控部署与配置

    cacti是一套基于PHP,mysql,SNMP及RRDTool开发的网络流量测试图形分析工具 cacti是通过snmpget来获取数据,使用RRDtool绘画图形 ,而且完全可以不需要了解RRDto ...

  10. Typescript变量声明

    let 和 const 是 javascript 里面最新的变量声明方式,let 与 var 很相似,而 const 是 let 的增强,能阻止对一个变量的再次赋值. var 声明 弱类型:var 声 ...