1、 基于 JAVA 的游戏设计 摘要 J2SE(Java 2 Simple Edition) 定位在客户端,主要用于桌面应用软件的编程,J2SE 包含于J2EE中, J2ME包含了J2SE的核心类, 但新添加了一些专有类。 因其拥有 “Write Once, run anywhere”的 Java 特性而提高开发的效率。 随着 JAVA 应用的日益普及、Java 在各种平台上的的实现,Java 应用程序一次编 译到处运行的特点逐渐体现出其影响力,对减少重复编程、提供快捷的跨平台应用起 着不可忽视的作用。本论文着眼于 JAVA 技术的应用,开发一款可用于各种平台之上 的游戏程序坦克大战。 本程序的
2、思路来自于日本任天堂公司在 20 世纪 80 年代开 发的 Battle City游戏,将老少皆宜的经典作品重新用 JAVA 进行了呈现,为更流行的 硬件平台提供应用软件。 关键词 JAVA;J2SE;游戏;坦克大战 Abstract J2SE is a kind of fast developing technology implemented on various devices especially mobile communication equipments. It focuses on application for consumptive electronic products,
3、 providing revolutionary solution to the intelligentization and diversification of the equipment. It improve the efficiency of the development process thanks to its “Write Once, run anywhere” nature. When cell phone is getting ever more popular nowadays, with the implementation of Java technology on
4、 mobile equipment, increment of capital on communication service exhibits its force on peoples everyday life, providing them ever fast information just in hand. This dissertation focuses on implementation of J2SE technology and has developed a commercial game suite run on mobile phonesTank. This app
5、lication inherits many characters of the old fashioned game Battle City which developed by Nintendo in 1980s. It transports the classical product to mobile phones, offering corresponding software for such more popular hardware platform. Keywords Java;J2SE;Game;TankWord 目录 摘要 . I Abstract II 第 1章 绪论
6、1 第 2章 开发环境及相关技术的介绍 . 3 2.1 开发环境 . 3 2.2 Java 语言的特点 . 3 2.3 关于 ECLIPSE. 4 第 3章 程序结构、思想和相关技术 . 5 3.1 本程序需解决的有关技术问题 5 3.2 程序截图 7 3.3 程序流程 8 3.4 相关技术 8 3.4.1 多态 . 8 3.4.2 单例模式 . 9 3.4.3 责任链模式 . 9 3.4.4 工厂模式 . 9 3.4.5 简单工厂模式 . 10 3.4.6 抽象工厂模式 . 10 3.4.7 策略模式 . 11 3.4.8 调停者模式 . 11 3.4.9 门面模式 . 11 3.4.10 PNG 格式 . 11 3.4.11 AWT 绘制的基本原理 12 3.4.12 双缓冲 . 12 3.5 程序思路 13 3.5.1 坦克的控制和敌方的智能运行 . 13 3.5.2 子弹的运行和控制 . 14 第 4章 程序分析和具体实现 . 16 4.1 主游戏逻辑及其涉及到的若干类 16 4.2 坦克的共同行为 19 4.3 玩家坦克的功能属性 19 4.4 敌人坦克的功能属性