当前位置:文档之家› Java(GUI)飞机大战

Java(GUI)飞机大战

Java(GUI)飞机大战
Java(GUI)飞机大战

此小程序适合java初学者练手之用

效果图

(Plane .java)

package beans;

import java.awt.Image;

import java.io.Serializable;

import javax.swing.ImageIcon;

public class Plane implements Serializable{

private Image myImage;

private int x;

private int y;

private int life;

private boolean isRun;

public Plane(Image myImage, int x, int y, int life, boolean isRun) { super();

this.myImage = myImage;

this.x = x;

this.y = y;

this.life = life;

this.isRun = isRun;

}

// public Plane(ImageIcon imageIcon, int x2, int y2, int life2, boolean isRun2) { // TODO Auto-generated constructor stub

// }

public Image getMyImage() {

return myImage;

}

public void setMyImage(Image myImage) {

this.myImage = myImage;

}

public int getX() {

return x;

}

public void setX(int x) {

this.x = x;

}

public int getY() {

return y;

}

public void setY(int y) {

this.y = y;

}

public int getLife() {

return life;

}

public void setLife(int life) {

this.life = life;

}

public boolean isRun() {

return isRun;

}

public void setRun(boolean isRun) {

this.isRun = isRun;

}

}

(FrmPlane .java)

package gui;

import java.awt.Color;

import java.awt.Font;

import java.awt.Graphics;

import java.awt.Image;

import https://www.doczj.com/doc/5210457515.html,youtManager;

import java.awt.Rectangle;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import java.util.ArrayList;

import java.util.List;

import java.util.Random;

import java.util.prefs.BackingStoreException;

import javax.sound.midi.Receiver;

import javax.swing.ImageIcon;

import beans.Plane;

import https://www.doczj.com/doc/5210457515.html,mon.FrmAdpter;

public class FrmPlane extends FrmAdpter{

ImageIcon icon,backImg,background;

int backy;//yzhou

Image bufferImg;

Plane hero,enemy,bullet;

Random rd=new Random();

int mark;

ArrayList emyList=new ArrayList();//敌机ArrayList bulList=new ArrayList();//子弹

public FrmPlane() {

super("飞机大战", 400, 480, false, true,0, 0, null);

//background=frmP.setIconImage("image/bgstar.gif");

backImg=new ImageIcon("image/bgstar.gif");

//this.setBackground(new Color(0, 130, 190));

icon=new ImageIcon("image/logo.png");//logo

super.setIconImage(icon.getImage());

hero=new Plane(new ImageIcon("image/hero.png").getImage(),160,390,3,true);

//"敌机"线程

Enemy am1=new Enemy();

Thread t2=new Thread(am1);

t2.start();

//"子弹"线程

Bullet b=new Bullet();

Thread tbul=new Thread(b);

tbul.start();

//敌机与子弹

EnemyBullet eb=new EnemyBullet();

Thread tEB=new Thread(eb);

tEB.start();

//"移动"线程

Move m=new Move();

m.fp=this;

Thread mThread=new Thread(m);

mThread.start();

this.addKeyListener(this);

this.setFont(new Font("koko", 10, 25));

this.setForeground(new Color(250,250,0));

super.setVisible(true);

}

//双缓冲

public void paint(Graphics g) {

// super.paint(g);再绘,闪屏

if(bufferImg==null) {

//画笔

bufferImg=this.createImage(this.getWidth(), this.getHeight());

}

//根据画笔创建一个画布,背景

Graphics g2=bufferImg.getGraphics();

g2.drawImage(backImg.getImage(),0,backy,null);

//英雄

g2.drawImage(hero.getMyImage(),hero.getX(),hero.getY(),null);

//敌机

for (int i = 0; i < emyList.size(); i++) {

g2.drawImage(emyList.get(i).getMyImage(),

emyList.get(i).getX(),emyList.get(i).getY(), null);

//子弹

for(int i=0;i

g2.drawImage(bulList.get(i).getMyImage(), bulList.get(i).getX(), bulList.get(i).getY(), null);

}

g2.drawString("分数:"+mark, 20, 450);

//缓冲画布一次性画到

g.drawImage(bufferImg,0,0,null);

}

//敌机生成

class Enemy implements Runnable {

//FrmPlane fp;

@Override

public void run() {

while(true) {

try {

Thread.sleep(1000);

Plane army=new Plane(new ImageIcon("image/enemy.png").getImage(), rd.nextInt(350)+30, 30, 1, true);//.getImage()

emyList.add(army);

} catch (InterruptedException e) {

e.printStackTrace();

}

}

}

}

//子弹生成

class Bullet implements Runnable {

public void run() {

while(true) {

try {

Thread.sleep(600);

Plane bullet=new Plane(new ImageIcon("image/bullet.png").getImage(),hero.getX()+40,hero.getY()-10,1,true);

bulList.add(bullet);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}

//敌机与子弹

class EnemyBullet implements Runnable {

public void run() {

while(true) {

for(int i=0;i

Plane Renemy=emyList.get(i);

for(int j=0;j

Plane Rbullet=bulList.get(j);

if(Renemy==null||Renemy.getMyImage()==null) {

break;

}

if(Rbullet==null||Rbullet.getMyImage()==null) {

break;

}

//将图片转换为矩形以便判断

Rectangle recEnemy=new Rectangle(Renemy.getX(),Renemy.getY(),Renemy.getMyImage().getWidth(null),

Renemy.getMyImage().getHeight(null));

Rectangle recBullet=new Rectangle(Rbullet.getX(),Rbullet.getY(),Rbullet.getMyImage().getWidth(null),

Rbullet.getMyImage().getHeight(null));

if(recEnemy.intersects(recBullet)) {//检测碰撞

emyList.remove(i);

bulList.remove(j);

mark++;

break;

}

}

}

}

}

}

//所有移动

class Move implements Runnable {

FrmPlane fp;

@Override

public void run() {

while(true) {

//画布坐标动

// backy--;

// if(Math.abs(backy)==1800) {

// backy=0;

// }

//敌人的飞机动

for (int i = 0; i < emyList.size(); i++) {

emyList.get(i).setY(emyList.get(i).getY()+2);

}

//子弹的移动

for(int i=0;i

bulList.get(i).setY(bulList.get(i).getY()-2);

}

try {

Thread.sleep(30);

} catch (InterruptedException e) {

e.printStackTrace();

}

fp.repaint();

}

}

}

//键盘移动事件

@Override

public void keyPressed(KeyEvent e) {

super.keyPressed(e);

char choice;

choice=e.getKeyChar();

switch (choice) {

case 'w':

hero.setY(hero.getY()-3);

break;

case 's':

hero.setY(hero.getY()+3);

break;

case 'a':

hero.setX(hero.getX()-3);

break;

case 'd':

hero.setX(hero.getX()+3);

break;

}

}

/*private class backThread implements Runnable {

FrmPlane fp;

@Override

public void run() {

while(true) {

backy--;

if(Math.abs(backy)==1500) {//1500即一个数值<画布长度-窗体长度

backy=0;

}

try {

Thread.sleep(20);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

fp.repaint();

}

}

}*/

public static void main(String[] args) {

new FrmPlane();

}

}

(FrmAdpter.java)

package https://www.doczj.com/doc/5210457515.html,mon;

import java.awt.Container;

import https://www.doczj.com/doc/5210457515.html,youtManager;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.FocusEvent;

import java.awt.event.FocusListener;

import java.awt.event.ItemEvent;

import java.awt.event.ItemListener;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.awt.event.MouseMotionListener;

import java.awt.event.WindowEvent;

import java.awt.event.WindowListener;

import javax.swing.JFrame;

public class FrmAdpter extends JFrame implements ActionListener,KeyListener,

MouseListener,MouseMotionListener,WindowListener,

FocusListener,ItemListener { protected Container container;

public FrmAdpter(String title,int w,int h,boolean resize,boolean location,int x,int y,LayoutManager layout)

{

super.setTitle(title);

super.setSize(w, h);

super.setResizable(resize);

if(location)

super.setLocationRelativeTo(null);

else

super.setLocation(x, y);

super.setDefaultCloseOperation(3);

container=super.getContentPane();

container.setLayout(layout);

}

@Override

public void itemStateChanged(ItemEvent e) {

// TODO Auto-generated method stub

}

@Override

public void focusGained(FocusEvent e) {

// TODO Auto-generated method stub

}

@Override

public void focusLost(FocusEvent e) {

// TODO Auto-generated method stub

}

@Override

public void windowOpened(WindowEvent e) {

// TODO Auto-generated method stub

}

@Override

public void windowClosing(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowClosed(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowIconified(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowDeiconified(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowActivated(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowDeactivated(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseDragged(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseMoved(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void keyTyped(KeyEvent e) {

// TODO Auto-generated method stub

}

@Override

public void keyPressed(KeyEvent e) {

// TODO Auto-generated method stub

}

@Override

public void keyReleased(KeyEvent e) {

// TODO Auto-generated method stub

}

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

}

}

(FrmDailogAdpter.java)

package https://www.doczj.com/doc/5210457515.html,mon;

import java.awt.Container;

import java.awt.Frame;

import https://www.doczj.com/doc/5210457515.html,youtManager;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.FocusEvent;

import java.awt.event.FocusListener;

import java.awt.event.ItemEvent;

import java.awt.event.ItemListener;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.awt.event.MouseMotionListener;

import java.awt.event.WindowEvent;

import java.awt.event.WindowListener;

import javax.swing.JDialog;

public class FrmDailogAdpter extends JDialog implements ActionListener,KeyListener, MouseListener,MouseMotionListener,WindowListener,

FocusListener,ItemListener {

protected Container container;

public FrmDailogAdpter(Frame owner,String title,int w,int h,boolean resize,boolean location,int x,int y,LayoutManager layout)

{

super(owner, true);

super.setTitle(title);

super.setSize(w, h);

super.setResizable(resize);

if(location)

super.setLocationRelativeTo(null);

else

super.setLocation(x, y);

super.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

container=super.getContentPane();

container.setLayout(layout);

}

@Override

public void itemStateChanged(ItemEvent e) {

// TODO Auto-generated method stub

}

@Override

public void focusGained(FocusEvent e) {

// TODO Auto-generated method stub

}

@Override

public void focusLost(FocusEvent e) {

// TODO Auto-generated method stub

}

@Override

public void windowOpened(WindowEvent e) {

// TODO Auto-generated method stub

}

@Override

public void windowClosing(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowClosed(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowIconified(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowDeiconified(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowActivated(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void windowDeactivated(WindowEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseDragged(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseMoved(MouseEvent e) {

// TODO Auto-generated method stub

}

@Override

public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub

}

@Override

public void keyTyped(KeyEvent e) {

// TODO Auto-generated method stub

}

@Override

public void keyPressed(KeyEvent e) {

// TODO Auto-generated method stub

}

@Override

public void keyReleased(KeyEvent e) {

// TODO Auto-generated method stub

}

@Override

public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub

}

}

飞机大战实验报告

飞机大战实验报告 专业:网络工程132班 学号:139074298 姓名:孙仁强 计算机科学与技术学院二零一六年十二月

一、软件运行所需要的软硬件环境 本系统是以Windows系统为操作平台,用Java编程语言来实现本系统所需功能的。本机器的配置如下: 处理器:CORE i7 主频:1.2Hz以上 内存:4G以上 硬盘:HHD 50G 编程语言:Java 开发环境:windows7 开发软件:Eclipse Mars 二、游戏流程 1.用户打开游戏,进入开始菜单。 2.用户点击开始游戏按钮,进入游戏界面; 3.用户通过触屏方式控制玩家飞机上下左右移动,躲避与子弹相撞; 4.游戏失败后,显示本次游戏得分,用的秒数和水平; 5.退出游戏 三、主要代码 1、准备代码设置窗口使用双缓冲使飞机不闪烁 Constant设置窗口大小 package com.ahut.准备代码; publicclass Constant { publicstaticfinalint GAME_WIDTH = 350; publicstaticfinalint GAME_HEIGHT = 600; } package com.ahut.准备代码; import java.awt.Image; import java.awt.image.BufferedImage;

import java.io.IOException; import https://www.doczj.com/doc/5210457515.html,.URL; public class GameUtil { private GameUtil () {} public static Image getImage(String path) { BufferedImage bi = null; try { URL u = GameUtil.class.getClassLoader().getResource(path); bi = javax.imageio.ImageIO.read(u); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bi; } } package com.ahut.准备代码; import java.awt.Frame; import java.awt.Graphics; import java.awt.Image; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class MyFrame extends Frame{ public void lauchFrame() { setSize(Constant.GAME_WIDTH, Constant.GAME_HEIGHT); setLocation(100, 100); setVisible(true); new PaintThread().start(); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); }

基于JAVA的飞机大战游戏的设计与实现计算机毕业设计论文

基于Java的飞机大战游戏的设计与实现 摘要 飞机大战是电脑游戏发展史中早期最为经典的游戏之一,经常能在掌上游戏机、手机以及电脑上见到这个游戏。不过,以往常见的飞机大战游戏是二维平面上的,并且大多以黑白的形式出现,当然在电脑上可以看到多种颜色的飞机大战。 Java自面世后就非常流行,发展迅速,对C++语言形成了有力冲击。Java 技术具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于个人PC、数据中心、游戏控制台、科学超级计算机、移动电话和互联网,同时拥有全球最大的开发者专业社群。在全球云计算和移动互联网的产业环境下,Java更具备了显著优势和广阔前景。 本游戏是一个基于java的飞机大战游戏,利用Eclipse平台实现经典的飞机大战游戏。游戏主要涉及了游戏状态控制功能、游戏难度的调整、游戏界面绘画功能、玩家游戏控制功能,最终展示了游戏开发的基本开发过程和设计思路。 关键词:飞机大战;游戏;java;Eclipse平台

Design and implementation of airplane wargame based on Java Abstract Lightning is the history of the development of computer games in the early one of the most classic game, often on a handheld game consoles, mobile phone and computer to see this game. However, the previous common lightning game is two-dimensional plane, and mostly in black and white, in the course of the computer can see lightning in color. Since Java is very popular after the launch, the rapid development of the C + + language to form a strong impact. Java technology has excellent versatility, efficiency, platform portability and security, widely used in personal PC, data center, game consoles, scientific supercomputers, cell phones and the Internet, also has the world's largest developer of professional community . In the world of cloud computing and mobile Internet industry environment, Java and more have a significant advantage and broad prospects. This game is a game based on the realization of Java lightning, lightning classic game based on Eclipse platform. The game is mainly involved in the game state control function, the difficulty of the game, the game interface to adjust the drawing function, game player control function, finally shows the basic development process of game development and design ideas. Keywords: lightning; game; Java; Eclipse platform

基于Unity3D的飞机大战游戏开发

摘要 Unity3D是由Unity Technologies开发,可以让玩家轻松创建诸如三维视频游戏、建筑可视化、实时三维动画等类型互动内容的多平台的综合型游戏开发工具,是一个全面整合的专业游戏引擎。Unity的编辑器运行在Windows 和Mac OS X 下,可发布游戏至Windows、Mac、iPhone和Android平台也可以利用Unity web player插件发布网页游戏,支持Mac 和Windows的网页浏览。它的网页播放器也被Mac widgets所支持。 本课题是基于Unity3D的飞机大战游戏开发,利用Unity3D系统和C#语言开发,实现了简单的飞机大战游戏。主要的功能模块如下:提供背景的循环播放模块,提供敌机的孵化器类模块,提供玩家战机的类模块,主界面模块,游戏奖励类模块,包括超级子弹和导弹,游戏控制模块,包括检测子弹与敌机碰撞,检测敌机与玩家战机碰撞木块,游戏的暂停、播放功能,其中玩家战机还添加了一个血条,玩家战机可以被敌机打中四次才死亡,可以让新手更好的试玩游戏,除此以外还为用户提供更加人性化的设计和方便人员的操作流程。 游戏还有很多需要完善和扩充的地方,比如可以做不同的模式,多关卡模式或挑战模式。也可以做成多人模式和小伙伴一起玩,游戏的界面也可以补充的更加完善,包括音乐、设置、帮助和商店等模块。后期还需要更加努力去完善修改自己的游戏 关键词:游戏开发;飞机大战;移动端;单机;碰撞检测;脚本语言

ABSTRACT Unity3D developed by Unity Technologies, allows gamers to easily create such comprehensive three-dimensional video game development tools, games, architectural visualization, real-time three-dimensional animation and other types of multi-platform interactive content, is a fully integrated professional game engine. Unity Editor runs under Windows and Mac OS X, you can publish your game to Windows, Mac, iPhone and Android platform can also use the Unity web player plugin released web games, support for Mac and Windows web browser. Its Web Player Mac widgets are also supported. This paper is based on Unity3D aircraft war game development, utilization Unity3D system and C # language, to achieve a simple airplane war game. The main function modules are as follows: to provide background loop module which provides the aircraft incubator class module offers players fighter class module, the main interface module, the game rewards class modules, including super bullets and missiles, the game control module, comprising detecting bullet collision with the enemy, and the player to detect enemy aircraft collision block, pause the game, the player, in which the player warplanes also added a health bar, the player can be enemy aircraft hit four times before death, allowing novices better demo games, in addition also provides users with the operation process more convenient and user-friendly design staff. Games have a lot to improve and expand the place, for example, can do different mode, multi-level mode or challenge mode. Multiplayer mode and can also be made small partner to play with, the game's interface can also add more sophisticated, including music, Settings, Help, and shops and other modules. Late also need to work harder to revise and improve their game. Keywords:Game Development; Aircraft War; Mobile Terminal; Single; Collision Detection; Scripting Language

java飞机大战项目总结

java飞机大战项目总结 :大战飞机项目 java 达内飞机大战项目总结java飞机大战项目描述j ava飞机大战答辩ppt 篇一:飞机大战JAVA程序设计报告 中国地质大学长城学院 Java 程序设计 题目基于Java的打飞机游戏设计与实现 系别信息工程系专业计算机科学与技术学生姓名马辉学号041120101 指导教师田玉龙 2015 年6 月18 日 基于Java的打飞机游戏设计与实现 1、软件运行所需要的软硬件环境 本系统是以Windows系统为操作平台,用Java编程语言来实现本系统所需功能的。本机器的配置如下: 处理器:AMD A4 或英特尔同级别处理器主频:1.2Hz以上内存:1G以上硬盘:HHD 50G或更高采用的主要技术和软件编程语言:Java 开发环境:windows7 开发软件:Eclipse 3.7 2、软件开发环境配置 JAVA_HOME = F:\JAVA\jdk PATH = % JAVA_HOME%\bin;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib;

CLASSPATH = %JAVA_HOME%\lib;%JAVA_HOME%\jre\lib; 3、软件功能框图 4、软件所实现的截图 5、主要功能部分的源代码 import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.Random; import java.util.Vector; import javax.swing.JOptionPane; import javax.swing.Timer; public class Controller extends KeyAdapter{ public static VectorBang bangs = new VectorBang(); public static VectorEBullet ebullets = new VectorEBullet(); public static VectorPBullet pbullets = new VectorPBullet(); public static VectorEPlane eplanes = new VectorEPlane(); public static PPlane pplane = new PPlane(); private GamePanel gamePanel; private Random random = new Random(); public static int baoZhaNum; public Controller(VectorBang bang,VectorEBullet ebullet,VectorPBullet pbullet, VectorEPlane eplane,PPlane pplane,GamePanel gamePanel) { super(); this.bangs = bang; this.ebullets = ebullet; this.pbullets = pbullet;

飞机大战--毕业论文--初稿

毕业设计(论文) 题目:基于安卓平台的飞机大战游戏 学院:计算机科学学院 专业班级:计算机科学与技术10级2班指导教师:黄国兵职称:高级工程师学生:兵 学号:41009010216

摘要 自从第一台计算机研发以来,计算机行业得到了迅速的发展,成就了很多优秀的企业,例如国外的IBM,微软,GOOGLE,ARM,苹果等,国的腾讯,阿里巴巴,百度等,而引领计算机行业的主要因素除了硬件的支撑外,就数操作系统了,而操作系统从Dos,UNIX,LINUX Windows等PC端正在逐渐向移动端转变如:从Linux 到Android;从Unix到IOS;从Windows到Windows phone,主要还是因为移动端的便携性,轻巧性深受人们的喜爱,就在这样的移动互联网浪潮中,Android系统更是高达移动端操作系统80%的占有率,真可谓前景无限,而在Android平台的应用中游戏业务又占着最大的比例,所以本次选题为基于Android的飞机大战游戏,其主要目的研究移动互联网的发展趋势,对其未来的发展有深刻清晰的认识。 本论文主要阐述以面向对象的程序开发语言Java及Eclipse为开发工具,而基于智能手机Android系统之上的飞机大战游戏。首先简要介绍课题的研究背景、目的及意义,Android的发展历程、当前国外的发展现状。然后介绍了Android 平台开发环境及环境搭建,最后讲述了基于Android飞机大战游戏功能的实现。其功能模块如下:提供敌机的类模块,提供子弹的类模块,主界面模块,天空背景模块,检测子弹与敌机碰撞模块,检测,敌机与我拥有的战机碰撞木块等,除此以外还为用户提供更加人性化的设计和方便人员的操作流程。由于Android 逐渐成为智能手机技术的主导,相信其基于Android的飞机大战游戏将会受到更大的欢迎。 关键字:安卓,游戏,飞行射击,飞机

飞机大战 java 源代码

package com; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Image; import java.awt.Rectangle; import java.awt.event.KeyEvent; import java.io.IOException; import javax.imageio.ImageIO; public class Plane { Image feijiImage = null; int x = 300; int y = 700; int lifeCount=5; public Plane() { try { feijiImage = ImageIO.read(Plane.class.getClassLoader() .getResourceAsStream("images/feiji.png")); } catch (IOException e) { e.printStackTrace(); } } public void draw(Graphics g) { // 画飞机图片 g.drawImage(feijiImage, x, y, null); // 飞机移动 this.move(); // 血条 if(lifeCount>0){ g.setColor(Color.WHITE); g.fillRect(20, 80, 100, 10); g.setColor(Color.red); g.fillRect(20, 80, (100/5)*lifeCount, 10); g.setColor(Color.blue); g.setFont(new Font("幼圆", Font.BOLD, 30)); g.drawString("Score:"+Play01.count, 20, 60); } }

飞机大战java源代码

飞机大战j a v a源代码 Document serial number【KK89K-LLS98YT-SS8CB-SSUT-SST108】

package com; import class Plane { Image feijiImage = null; int x = 300; int y = 700; int lifeCount=5; public Plane() { try { feijiImage = .getResourceAsStream("images/")); } catch (IOException e) { (); } } public void draw(Graphics g) { etResourceAsStream("images/")); } catch (IOException e) {

(); } } public void draw(Graphics g) { etResourceAsStream("images/")); } catch (IOException e) { (); } } int bgY1 = 0; int bgY2 = -600; int fireTime = 0; boolean flag=false; public void draw(Graphics g) { tart(); etResourceAsStream("images/"));

} catch (IOException e) { (); } } public void draw(Graphics g) { etResourceAsStream("images/diji_"+r+".png")); } catch (IOException e) { (); } } public void draw(Graphics g) { etResourceAsStream("images/")); } catch (IOException e) { (); } }

飞机大战游戏开发开题报告

飞机大战游戏开发开题报告 打飞机小游戏开题报告 毕业设计开题报告 篇二:基于android的飞机游戏开发开题报告 开题报告 (1)研究的目的和意义 Android操作系统最初是由 Andy Rubin制作,最初主要支持手机,在2005年被搜索巨头Google收购注资,并组建开放手机联盟开发改良随后,逐渐扩展到平板电脑及其他领域上,2008年全球第一步安卓智能手机问世,标志着安卓的重生。而在2011年11月份的调查,android智能机一跃超过苹果,以全球市场占有率76%,中国90%遥遥领先。在安卓手机中以三星的GALAXY III系列为领头羊,领跑安卓手机最新科技。 当人类步入21世纪,随着科技的日趋发展,智能手机,平板电脑等高端电子产品进入了我们的日常生活,随着3G时代已经慢慢的融入了我们的日常生活,随着社会的进步和科技的发展手机已经从单纯的通讯工具转变为集娱乐,学习,通讯为一体的高端电子产品,随着诺基亚塞班系统的没落,安卓系统迎来了春天。据市场调查,智能手机市场已经形成了二足鼎力的态势,安卓和苹果的IOS作为领军者遥遥领先于windows phone 系统,而在2011年11月份的调查,android智能机一跃超过苹果,以市场占有率76%遥遥领先。同时各种android应用程序已经有了比较明朗的发展前景,尤其以手机游戏这个亮点受到广泛的关注和喜爱,正是由于android拥有广大的用户群,android手机游戏拥有巨大的潜力,它也主宰者手机游戏的未来,此次毕业设

计顺应时代发展潮流,依托现在硬件上的优势,以android为平台,旨在玩家打造一款优秀的飞行类小游戏,使玩家身临其景,爱不释手。 在安卓游戏的市场上,使得android手机游戏种类更加丰富多彩,为安卓手机游戏的发展做出贡献。 (2)国内外同类研究的概况 手机游戏种类和资源日益丰富,游戏界面越来越华丽,游戏规则日益复杂,已经具备了很强的娱乐性和交互性的复杂形态。 2003年10月,Andy Rubin等人创建了Android公司,google公司于2005年8月17日低调收购android以及其团队,Andy Rubin成为Google公司android项目工程部副主任,,在三年后的 GoogleI/O大会上谷歌提出android HAL 架构图,同年九月,谷歌发布android 1.0,这就是android的最早的版本,由于当时受到硬件技术的局限和3D技术的不完善,以及android没有得到公众的认可,所以当时安卓手机游戏并没有得到良好的发展,没有进入人们的日常生活,仅仅只能做出原始的简单的小游戏,而且玩家也不是很多。 时间来到了2011年,android操作系统以绝对的优势领跑只能手机界,而基于良好的平台支持和硬件的发展,使得android手机游戏得到了飞速的发展。 1基于良好的硬件制作更好效果的游戏 随着各平台对OpenGL ES支持能力的大力加强,使得开发复杂的3D场景游戏成为可能。更多显示芯片对Android的支持,硬件性能将不再成为制约专业化游戏发展的瓶颈。越来越多在PC、PSP、 PS3、XBOX360等各游戏平台占有领先地位的专业游戏公司将向Android等手机平台领域快速渗透,使得游戏的规划更加向专业化方向发展。随

基于Java的飞机大战游戏开发

毕业设计(论文) 题目基于Java的飞机大战游戏开发

飞机大战是电脑游戏发展史中早期最为经典的游戏之一,无论是在电脑端、移动端、还是游戏机上,都能见到与飞机相关的射击类游戏。不过,最初常见的飞机大战游戏是二维平面上的,并且大多以黑白的形式出现,而如今,在电脑上,不仅机型多,而且五颜六色,3D视觉冲击强。 Java自面世后就非常流行,发展迅速,对C++语言形成了有力冲击,Java技术具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于个人PC、数据中心、游戏控制台、科学超级计算机、移动电话和互联网,同时拥有了全球最大的开发者专业社群。在全球云计算和移动互联网的产业环境下,Java更具备了显着优势和广阔前景。 因此,本论文主要阐述以面向对象的程序开发语言Java及Eclipse为开发工具的飞机大战游戏。首先简要介绍课题的研究背景、目的及意义,Java的发展历程、当前国内外的发展现状。然后介绍Eclipse平台开发环境及环境搭建,最后讲述了基于Java飞机大战游戏功能的实现。其功能模块如下:主界面模块,Hero模块,Enemy模块,Bullet 的类模块,检测子弹与敌机碰撞模块检测,相信其基于Java的飞机大战游戏将会受到更大的欢迎。 关键词:飞机大战,游戏,Java ,Eclips

Plane War is the one of the most classic games in the early history of the development of computer games. We can always see aircraft-related shooting game whether it is on a computer teminal or mobile terminal. However, the first common plane war game is a two-dimensional plane, and mostly appears in the form of black and white, but now, on the computer, not just models and more colorful, 3D strong visual impact. Java is very popular with developers since it appeared, formed the powerful shock for the rapid evelopment of the C++ language. Java technology has excellent versatility, efficiency, platform portability, and security and is widely used in personal PC, data center, game consoles, scientific supercomputers, cell phones and the Internet. What’s more, Java has the world's largest developer of professional community. In the global cloud computing and mobile Internet industry environment, Java has more significant advantages and broad prospects. Therefore, this paper describes the development of object-oriented programming language Java and Eclipse development tools for aircraft war game. Firstly, it introduces research background, purpose and meaning, and telled Java development process and the current development status at home and abroad. Then introduces the Eclipse platform development environment and built environment, and finally tells the Java-based aircraft war game features implementation. Its function modules are as follows: the main interface module,Hero module,Enemy module,Bullet module, and the detection module detecting a collision with the enemy bullets. We believes its Java-based aircraft war game would be welcomed

飞机大战源代码

package com.Tak; import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.image.ImageObserver; import java.util.Vector; import javax.swing.*; public class TakGame extends JFrame { MyPanel mp=null; public static void main(String[] args) { // TODO Auto-generated method stub TakGame tg=new TakGame(); } //构造函数 public TakGame() { mp=new MyPanel(); //启动线程 Thread t=new Thread(mp); t.start(); this.add(mp); this.addKeyListener(mp); this.setLocation(400, 90); this.setSize(400, 600); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } } //面板 class MyPanel extends JPanel implements KeyListener,Runnable { //定义一个my坦克 MyTk mytk=null; //定义敌人坦克 Vector drtk=new Vector(); int drtksize=4; int x; int y; //重写paint public void paint(Graphics g){

大学课程设计报告-飞机大战

湖北大学本科课程设计 题目Java课程设计——飞机大战 姓名学号 专业年级 指导教师职称 2015年12月18日

----目录---- 一.项目介绍-------------------------------- 1二.概要设计 2.1资源需求------------------------------ 1 2.2游戏流程------------------------------ 1三.类设计 3.1游戏界面类---------------------------- 2 3.2飞行物类------------------------------ 2 3.3敌机类-------------------------------- 2 3.4蜜蜂类-------------------------------- 3 3.5玩家飞机类----------------------------- 3 3.6子弹类-------------------------------- 4四.编码分析 4.1游戏界面类---------------------------- 4 4.2飞行物类------------------------------ 11 4.3敌机类-------------------------------- 12 4.4蜜蜂类-------------------------------- 13 4.5玩家飞机类----------------------------- 13 4.6子弹类-------------------------------- 15五.游戏测试画面----------------------------- 16六.总结------------------------------------ 18

飞机大战 JAVA程序设计报告

中国地质大学长城学院Java 程序设计 题目基于Java的打飞机游戏设计与实现 系别信息工程系 专业计算机科学与技术 学生姓名马辉 学号041120101 指导教师田玉龙 2015 年 6 月18 日

基于Java的打飞机游戏设计与实现 1、软件运行所需要的软硬件环境 本系统是以Windows系统为操作平台,用Java编程语言来实现本系统所需功能的。 本机器的配置如下: 处理器:AMD A4 或英特尔同级别处理器 主频:1.2Hz以上 内存:1G以上 硬盘:HHD 50G或更高 采用的主要技术和软件 编程语言:Java 开发环境:windows7 开发软件:Eclipse 3.7 2、软件开发环境配置 JA V A_HOME = F:\JA V A\jdk PATH = % JA V A_HOME%\bin;%JA V A_HOME%\lib;%JA V A_HOME%\jre\lib; CLASSPATH = %JA V A_HOME%\lib;%JA V A_HOME%\jre\lib; 3、软件功能框图 4、软件所实现的截图

5、主要功能部分的源代码 import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.Random; import java.util.Vector; import javax.swing.JOptionPane; import javax.swing.Timer; public class Controller extends KeyAdapter{ public static Vector bangs = new Vector(); public static Vector ebullets = new Vector(); public static Vector pbullets = new Vector(); public static Vector eplanes = new Vector(); public static PPlane pplane = new PPlane(); private GamePanel gamePanel; private Random random = new Random(); public static int baoZhaNum; public Controller(Vector bang,Vector ebullet,Vector pbullet, Vector eplane,PPlane pplane,GamePanel gamePanel) { super(); this.bangs = bang; this.ebullets = ebullet; this.pbullets = pbullet; this.eplanes = eplane; this.pplane = pplane; this.gamePanel = gamePanel; //使用定时器每隔一秒为每一个敌机产生一个子弹 Timer timer = new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub for(int i=0;i < eplanes.size();i++){ EBullet ebullet = new EBullet(eplanes.elementAt(i).x, eplanes.elementAt(i).y,8,2); ebullets.add(ebullet); }

飞机大战游戏设计报告

J A V A期中作业 飞 机 大 战 目录 飞机大战游戏设计报告 1、游戏名称 ....................................................................................................................................... 2、游戏初步框架:............................................................................................................................ 3、游戏规则: ................................................................................................................................... 4、需求分析 ....................................................................................................................................... 4.1功能需求: ............................................................................................................................. 4.2数据需求: ............................................................................................................................. 4.3用户需求: ............................................................................................................................. 4.4行为需求: ............................................................................................................................. 5、系统设计 ....................................................................................................................................... 5.1 系统模块划分......................................................................................................................... 5.2 主要功能模块......................................................................................................................... 6、详细设计 ....................................................................................................................................... 6.1 开发工具 ................................................................................................................................ 6.2 游戏界面设计.........................................................................................................................

相关主题
文本预览
相关文档 最新文档