为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

手机吞吃蛇游戏的设计与开发

2017-10-29 50页 doc 250KB 29阅读

用户头像

is_841159

暂无简介

举报
手机吞吃蛇游戏的设计与开发手机吞吃蛇游戏的设计与开发 毕业设计(论文) 手机吞吃蛇游戏的设计与开发 论文作者姓名: 申请学位专业: 申请学位类别: 指导教师姓名,职称,: 论文提交日期: 手机吞吃蛇游戏的设计与开发 要 摘 J2ME(Java 2 Micro Edition) 是近年来随着各种不同设备,尤其是移动通信设备的飞速发展而诞生的一项新的开发技术。它定位在消费性电子产品的应用上,对设备的智能化、多样化,提供了革命性的解决方案,并因其“Write Once, run anywhere”的Java特性而提高开发的效率。 随着手机...
手机吞吃蛇游戏的设计与开发
手机吞吃蛇游戏的设计与开发 毕业设计(论文) 手机吞吃蛇游戏的设计与开发 论文作者姓名: 学位专业: 申请学位类别: 指导教师姓名,职称,: 论文提交日期: 手机吞吃蛇游戏的设计与开发 要 摘 J2ME(Java 2 Micro Edition) 是近年来随着各种不同设备,尤其是移动通信设备的飞速发展而诞生的一项新的开发技术。它定位在消费性电子产品的应用上,对设备的智能化、多样化,提供了革命性的解决,并因其“Write Once, run anywhere”的Java特性而提高开发的效率。 随着手机的日益普及、JAVA功能在移动设备上的实现,JAVA应用程序产生的手机增值服务逐渐体现出其影响力,对丰富人们的生活内容、提供快捷的资讯起着不可忽视的作用。本文主要介绍了一款手机吞吃蛇游戏,本设计着眼于J2ME技术的应用,采用JDK1.6,NetBeans 5.5作为开发工具,使用WTK2.5作为模拟器测试,开发一款吞吃蛇的手机游戏程序。本程序将老少皆宜的经典作品移植到手机上来,为更流行的硬件平台提供应用软件。这些都将能很好的满足未来人们对手机游戏的需求。吞吃蛇游戏基于JAVA平台编写,满足一般手机用户的娱乐需求。 关键词: J2ME;手机游戏;Java,吞吃蛇 The Design and the development of the gobbled snake mobile game Abstract J2ME (Java 2 Micro Edition) was a new development technology which born based on each different kinds of equipment, especially the rapid development of mobile communication equipment. It locates in the application of the expensive electronic products, has provided the revolutionary solution to the intellectualization and the diversification of the equipment and enhances the development the efficiency because of the Java characteristic that "Write Once, run anywhere" With the popularization of the handset and the realization of the JAVA function on the mobile equipment The increment service of the handset which produced by the JAVA application procedure gradually manifests its influence,and plays a noticeable role on riching people's life content and providing the quick information.This thesis mainly introduced a gobbled snake game in the handset, this design focuses on the application of the J2ME technology, takes JDK1.6, NetBeans5.5 as the developmentkit, uses WTK2.5 as the simulator to test, develops a handset game procedure of the gobbled snake game. This procedure transplants the classical work which both good for young and old to the handset, provides the application software for the more popular hardware platform. These will be able to satisfy the peoples' demands to the handset's games. The gobbled snake game based on the JAVA platform compilation, satisfied the entertainment demand of the common handset user. Keyword: J2ME; Handset game; Java, the gobbled snake 目 录 论文总页数:21页 1引 言 ................................................................................................................................ 1 2手机吞吃蛇游戏系统分析 .................................................................................................. 2 2.1系统需求分析 ............................................................................................................. 2 2.1.1游戏背景 ....................................................................................................... 2 2.1.2游戏功能 ...................................................................................................... 2 2.1.3游戏的操作性要求: .................................................................................... 3 2.1.4 游戏的实用性 .............................................................................................. 3 2.2系统设计目标 ............................................................................................................. 3 2.2.1游戏设计思想 ............................................................................................... 3 2.2.2 模块框架结构 .............................................................................................. 4 2.2.3 关键技术问题 .............................................................................................. 4 2.3系统开发环境 ............................................................................................................. 5 2.4系统运行环境 ............................................................................................................. 5 3贪吃蛇游戏系统设计 .......................................................................................................... 6 3.1程序流程 ..................................................................................................................... 6 3.1.1结构构造 ...................................................................................................... 6 3.1.2系统流程图 .................................................................................................. 6 3.1.3系统流程说明 ............................................................................................... 7 3.2数据结构设计 ............................................................................................................. 8 4系统实现及核心代码........................................................................................................ 11 4.1系统实现 ................................................................................................................... 11 4.2 核心代码 .................................................................................................................. 13 5系统测试 .......................................................................................................................... 15 5.1测试方法 ................................................................................................................... 15 5.2 测试结果 .................................................................................................................. 15 5.3 测试结论 .................................................................................................................. 17 5.4 程序运行截图 .......................................................................................................... 17 结 论 ................................................................................................................................ 19 参考文献 ............................................................................................................................. 19 致 谢 ............................................................................................................................. 20 声 明 ............................................................................................................................. 21 1引 言 在信息社会中,手机及其他无线设备越来越多的走进普通百姓的工作和生活,随着信息网络化的不断进展,手机及其他无线设备上网络势在必行。但是传统手机存在以下弊端: 1.传统手机出厂时均由硬件厂商固化程序,程序不能增加、删除,有了错误也不能更新、修改,若要增加新功能必须另换一部手机。 2.传统手机访问互联网是通过WAP,所有网络资源必须接通网络才能在线访问,非常耗时、费用亦很高。 而JAVA技术在无线应用方面的优势非常明显: 1.应用程序可按需下载,而不是购买由硬件商提供的套件,可升级空间大。 2.JAVA技术提供了一个类库,它使的应用开发商可以创建更为直觉、丰富的用户界面; 3.JAVA技术使网络带宽的应用更为有效,因为应用程序可以下载到器件上,并在本地运行,仅仅是在连接到服务器时才会占用网络带宽。 基于以上分析,JAVA手机将是未来手机的发展方向,是业界的热点。 J2ME(Java 2 Micro Edition) 是近年来随着各种不同设备,尤其是移动通信设备的飞速发展而诞生的一项新的开发技术。它定位在消费性电子产品的应用上,对设备的智能化、多样化,提供了革命性的解决方案,并因其“Write Once, run anywhere”的JAVA特性而提高开发的效率。 JAVA手机游戏在国内大约开始于2004年,由于市场不规范,出产了一批非常劣质的手机游戏,不过那些开发商和运营商都从中挣到了钱。由于JAVA语言本身的特点,JAVA游戏不会受到手机平台的太大的限制,所以很是受欢迎。本文就将以计算机网络为载体,利用JAVA技术对吞吃蛇游戏的功能模块做一次尝试。 丰富的社会交互: 不管一个游戏设计得多好,只要玩家找到了它的根本模式或者玩完了所有的游戏路径很快就会厌烦这个游戏。对于一个基于订阅的游戏,重要的是与别的玩家合作以增强所玩游戏的智力和随机性。在今天纷繁复杂的多玩家游戏中具有丰富社会交互的游戏证明是成功的。 利用手机技术的优点:巨额的手机技术研发费用都花在提高设备和网络的可用性和可靠性上面。因此,手机设备硬件和网络协议与桌面/控制台世界(如全球定位系统(GPS)扩展、条形码扫描仪、和短消息服务(SMS)/多媒体信息服务(MMS)通讯)有着非常大的差别。好的手机游戏应该利用那些更新的设备特征和网络基础设备的优点。 游戏是人们生活中不可或缺的,一个人从小到大,真正伴随他成长的东西,游戏占有着很重要的地位.不论是一个玩具,还是一个能和伙伴一起开心的小游戏, 第 1 页 共 21 页 都是能给我们留下很多美好的回忆.所以不论是什么样的游戏,只要它能迎合人们内心的某种需求,它的市场总会是好的. 2手机吞吃蛇游戏系统分析 2.1系统需求分析 2.1.1游戏背景 贪吃蛇,是个简单的小游戏,但却能给人以放松,让我们从繁重的日常生活中解脱出来.而只有我们的身心得到了娱乐才能更好的投入到新的工作.现在的人,不管是已经工作的,还是还未进入社会的学生,都面临着很大的压力,而这样一款能让我们随时随地都能享受的游戏,其魅力还是不可估量的. 贪吃蛇,之所以取这样的名字,去用意还是很明显的.贪吃蛇其实并不贪,它是人不断向前追求的象征.就像现代的人只有不断努力向前才能得到自己想要的.而食物也是随机出现的,就像现在社会存在的机会,而我们只有找好自己的目标才能成功. 虽然现在市面上存在着各种各样的游戏版本,可是贪吃蛇其市场还是相当大的.因为它的特殊在于它能吸引人更深入,爱不释手.随着游戏速度不断加快,其刺激性也更强. 可以说该游戏的优势在于它的简单易行,不论是手机,还是小游戏机,都能很快顺利的运行.对于在外忙碌的人,不可能花费大量时间在娱乐上,大型游戏是行不通的,这样的小游戏刚好迎合了他们的需求. 手机吞吃蛇游戏基于JAVA平台编写,采用J2ME技术开发的一款手机游戏。手机游戏程序是一项精度要求很高的程序系统,因为其代码利用率很高。一个实时运行的最终作品,每秒都会运行成千上万行程序,绘图事件、键盘事件都会以极高的频率在后台等待响应,若有丝毫的差别都将很容易导致程序在运行不久后可能出现严重错误,甚至死循环。因此,其逻辑设计应当相当严谨,需将所有可能发生的事件及意外情况考虑在设计中。JAVA是基于虚拟机的半解释型编译系统,其执行效率较C++等完全编译后的程序会低很多,程序如果不进行精简和优化,将可能导致运行的不流畅。游戏的结束、开始、动态信息画面作为构成一个程序都是必不可少的重要部分。良好的用户界面更是吸引用户的硬指标,相关的美术构图和人性化设置也需要有一定的考虑。 2.1.2游戏功能 本游戏对游戏声音的控制、游戏等级的控制、最高分的记录、游戏暂停、游戏重新开始、游戏结束这些功能都要求能在手机模拟器上运行。 第 2 页 共 21 页 贪食蛇的玩法很简单,用键盘上的方向键控制贪食蛇的运动方向,游戏的目的是控制贪食蛇吃掉更多的食品,但是不能碰到四周的墙壁,也不能让贪食蛇的首尾相接,否则游戏失败。游戏最终是要在手机上允许。能够使用键盘控制贪食蛇的运动,生成新的点,并且能够根据点数进行记分. 2.1.3游戏的操作性要求: 易于学习: 既然手机游戏面向的是普通消费者而不是计算机专家,那么他们不可能深入的学习游戏技巧。消费者不会花几个小时去研究一个3元的手动操作的游戏。保持游戏的简单是最基本的要求。 可中断性: 多任务处理是手机生活方式的基本特征。手机用户常常在任务(如等一个电子邮件或者等车)之间有一小段时间。而游戏、日历管理、通讯和工作数据访问使用的是同一个设备。所以一个好的手机游戏应该提供短时间的娱乐功能,并且允许用户在游戏和工作模式之间顺利切换。 2.1.4 游戏的实用性 丰富的社会交互: 不管一个游戏设计得多好,只要玩家找到了它的根本模式或者玩完了所有的游戏路径很快就会厌烦这个游戏。重要的是与别的玩家合作以增强所玩游戏的智力和随机性。在今天纷繁复杂的多玩家游戏中具有丰富社会交互的游戏证明是成功的。 2.2系统设计目标 2.2.1游戏设计思想 本科期间做过很多课程设计,大多规模很小。在数据库、各种应用软件和游戏中,我仍觉得对游戏的设计有极大的热情。因为其各个模块间的联系十分紧密,代码重复执行率高,当经过无数次的调试、修改后,能最终看到成品,有无比自豪的心情。大学期间做过图书馆管理程序等简单的数据库管理系统的课程设计,思想大致相似,变化范围有限,没有太多自己可发挥的余地。大家作品的最终结果都离不开同一个模式。相比一些数据库软件,游戏的设计有很多人情色彩和艺术思想的发挥,正式商业的软件的人性化界面和各个游戏间迥异的结构每每会让人有去开发的冲动。综合运用以前所学习的知识,设计一个JAVA手机游戏,并能实现以下的功能:游戏声音的控制、游戏等级的控制、最高分的记录、游戏暂停、游戏重新开始、游戏的结束。 手机已经与现代生活方式紧紧地结合在一起。他们是最普遍携带的个人用品中仅次于钥匙和钱包的东西。传统的台式机游戏将目标锁定在低级趣味的人和青少年身上,而手机游戏则每个人都可以访问的到——随时,随地。尽管每个手机游戏都不贵,但是巨大的使用量(如:每人每星期一个新游戏)将使得这个市场商 第 3 页 共 21 页 机无限。但是,对于开发者来说,将控制台游戏迁移到手机游戏工程很大。因为他们所面向的对象、生活方式和分布式模型都有着极大的区别。 由于J2ME平台被认为是最杰出的手机游戏平台,它为开发者、设备制造商、网络通信公司和消费者广泛接受。它有一些非常重要的特征对所有组织都有益。因此本文采用它来进行设计。利用Java撰写手机上的程序当然有其缺点,最广为人知的可能就是执行效率的问题,Java在执行速度这个议题上一直让人诟病。不过笔者认为,随着技术的发达,将会有更快更省电的嵌入系统专用CPU出现,Java One中也传出将针对J2ME开发专用芯片,让Java在 手机上的程序可以跑得更快,因此效率上的总是其实是可以忽略的。更何况,当Sun在设计J2ME的时候,也用了很多方式企图加快Java 在手机上的执行速度。 2.2.2 模块框架结构 贪食蛇游戏是一条不停游动的蛇不断的捕食来达到自身的增长,但是若蛇碰到自身的身体或者碰到了任何障碍物,则游戏结束。 设计初期要做的工作 寻找规律,建立对象模型: 首先从物理的角度来分析蛇的运动规律。它是蠕动的,像水一样流动。他有个特性就是身体的每一个点都经过他头部所在的点,他每一个时刻骨节所要运动的目的地是他前一个骨节所在的位置。 不难看出,其中的对象模型为: 蛇,骨骼,骨节,头 抽象的接口为: 蛇,骨骼,骨节,头,图元 接下来将各个流程分解成模块,开始编码。 2.2.3 关键技术问题 本程序需解决的有关技术问题 1.游戏程序是一项精度要求很高的程序系统,因为其代码利用率很高。一个实时运行的最终作品,每秒都会运行成千上万行程序,绘图事件、键盘事件都会以极高的频率在后台等待响应,若有丝毫的差别都将很容易导致程序在运行不久后可能出现严重错误,甚至死循环。因此,其逻辑设计应当相当严谨,需将所有可能发生的事件及意外情况考虑在设计中。 2.游戏中为了美观,适用性强,可能需要采用外部文件引入的图片贴图,有关贴图,在MIDP2.0中提供了用于增强游戏功能的game包,使得解决静态或动态、画面背景、屏幕刷新的双缓冲等都有较好的解决方案。 第 4 页 共 21 页 3.一开始就把模块划分好,这样就可以简单而有效地避免了牌的重复,也可以大大地简化了程序代码的编写。 4.蛇的位置的转化可以用一个函数来实现,这样就可以使代码更模块化,利用也就可以更高。 5.蛇慢慢移动的实现。蛇的移动是用线程来实现的,用Thread.sleep() 这个函数来作时间延迟,让坐标变量缓慢地变化。然后通过刷新画图,就会 使人觉得牌是在缓慢地移动。 6.除开发过程中对结构上的控制、变量的使用、算法的优化等优化外,还可以使用混淆器(Obfuscator)进行程序打包后的优化。 以上相关技术细节和整体流程将分别在以下小节阐述。 2.3系统开发环境 本系统开发环境采用新推出的NetBeans 5.5。 NetBeans 5.5是全新的可视化编程环境,为我们提供了一种方便、快捷的Windows应用程序开发工具。它通用性高,开发出的应用程序可保证能运行在大部分设备上,而不像专用厂商具有一定的不兼容性。虽然它没有强大的功能和完善的调试手段,但它提供运行模拟器的最基本组件,是其他IDE需集成采用的必备元素。您将会发现编程不再是枯燥无味的工作,NetBeans 5.5的每一个设计细节,都将带给您一份欣喜。 2.4系统运行环境 , 硬件环境: CPU:Intel Pentium-M 725 1.6GHz 内存:512 MB 硬盘:60 G , 软件环境: 操作系统:Microsoft Windows XP Professional 应用软件:WTK 2.5 WTK 的全称是Sun J2ME Wireless Toolkit —— Sun的无线开发工具包。这一工具包的设计目的是为了帮助开发人员简化j2me的开发过程。使用其中的工具可以开发与 Java Technology for the Wireless Industry (JTWI, JSR 185) 规范兼容的设备上运行的j2me 应用程序。该工具箱包含了完整的生成工具、实用程序以及设备仿真器。WTK是用来开发MIDP的,为了让MIDlet可以顺利编译和执行,WTK必须具有CLDC和MIDP的类库,WTK可以帮助我们省去额外安装调试这些类库的时间 第 5 页 共 21 页 3贪吃蛇游戏系统设计 3.1程序流程 3.1.1结构构造 MIDlet suite是MIDP应用程序的最小单位,JAM负责将手机内的MIDlet suite以图形化的方式呈现,让用户能够选取欲执行的MIDlet suite,一旦选取了某个MIDlet suite,操作系统就会激活KVM执行里面的MIDlet。MIDlet及相关的支持类组成了MIDP应用程序的实际内容。而每个MIDlet都必须继承javax.microedition.midlet.MIDlet这个抽象类。在MIDP规范中定义了MIDlet的生命周期,以及可以存在的三种状态,包括Paused、Active以及Destroyed,每一个MIDlet在任何时刻只可能处于其中的一个状态。这三种状态的转换关系如图1所示:MIDlet有三个状态,分别是pause、active和destroyed。在启动一个MIDlet的时候,应用管理软件会首先创建一个MIDlet实例并使得他处于pause状态,当startApp()方法被调用的时候MIDlet进入active状态,也就是所说的运行状态。在active状态调用destroyApp(boolean unconditional)或者pauseApp()方法可以使得MIDlet进入destroyed或者pause状态。值得一提的是destroyApp(boolean unconditional)方法,事实上,当destroyApp()方法被调用的时候,AMSMIDlet进入destroyed状态。在destroyed状态的MIDlet必须释放了所有的资源,并且保存了数据。如果unconditional为false的时候,MIDlet可以在接到通知后抛出MIDletStateChangeException而保持在当前状态,如果设置为true的话,则必须立即进入destroyed状态。 呼叫MIDlet的构造函数 StartApp() DestroyApp() 停止状态 (Paused) 运行状态 消减状态 PauseApp() (Active) (Destroyed) DestroyApp() 图1:状态转换关系图 3.1.2系统流程图 本程序采用面向对象的设计模式,对游戏中的所有物体赋予对象的概念和属 第 6 页 共 21 页 性。运行程序后允许用户选择执行选项菜单,画面刷新将以一定的频率采用双缓冲技术对屏幕重绘,实时反映整个游戏的进行状态。 系统流程图,如图2: 图2:系统流程图 3.1.3系统流程说明 上图主要展示游戏的进行控制流程图,这里说明一下流程。首先当游戏运行时将对玩家进行按键进行检测,同时对方向进行响应。这里的响应主要是在屏幕上显示蛇的移动方向,同时还会检测当前蛇的状态。如果蛇头碰到蛇尾或者蛇头碰到墙壁都会导致游戏结束。当蛇头碰到蛋的时候,会进行家分,同时在屏幕上显示出来。 同时这里还有其他按键检测,主要是对菜单按键检测。菜单按键检测包括退 第 7 页 共 21 页 出和系统设置。当游戏中检测到退出按键时,游戏结束。当游戏中检测到菜单按键时进行菜单按键事件处理,主要是设置游戏暂停,等级和音效开关。 3.2数据结构设计 节:一条蛇可以看成有许多正方形的“小格子”拼凑成,我把它称作节。节是蛇身上最小的单位。 段:当许多节连成一条直线,我称它为段。贪吃蛇只有一段,如果它拐弯就变成两段。 链表:用来保存每一段的状态,链表的元素单位是段。且链表的最后一个元素表示蛇的头部段。 坐标系:MIDP中的坐标以左上角那点为(0,0),向右则x递增,向下则y递增。 这里讲解数据结构类中主要属性,其他方法将在后面讲解。 这里用一个SnakeLink类来表示一个蛇身体节点对象: public class SnakeLink { private int x, y;//坐标 private int len;//长度 private byte dir;//方向 private SnakeLink() { } „„ } 这里用SnakePit类来表示一个蛇对象的基本游戏属性: public class SnakePit extends Canvas implements Runnable { //蛇的食物 private SnakeFood myFood; //当前蛇对象 private Snake mySnake; //结束标志 private boolean gameOver = false; //暂停标志 private boolean gamePaused = false; //重来标志 private boolean gameRestart = false; //重画标志 第 8 页 共 21 页 private boolean forceRedraw = true; //退出游戏标志 private boolean gameDestroyed = false; //当前得分 private int score = 0; //当前等级 private int level = 5; //吃到多少食物 private int foodEaten = 0; //当前屏幕象素宽 private int width; //当前屏幕象素高 private int height; //音效对象 private Player audioPlayer; //音效对象 private Player tonePlayer; //一个屏幕单元格宽 static int CellWidth; //一个屏幕单元格高 static int CellHeight; //初始蛇位置 private static final int START_POS = 3; //重画时间 private static final int DEFAULT_WAIT = 400; //最高难度 static final byte MAX_LEVELS = 10; //食物颜色 static final int FOOD_COLOUR = 0x0000ff00; //文字颜色 static final int TEXT_COLOUR = 0x00ff0000; //擦除颜色 static final int ERASE_COLOUR = 0x00ffffff; //蛇节点颜色 第 9 页 共 21 页 static final int DRAW_COLOUR = 0x00000000; //一个单元大小 public static final int CELL_SIZE = 5; „„ } 最后一条蛇对象由Snake类将以上两个类又机组织在一起在游戏中使用。 public class Snake { //方向常量 public final static byte DOWN = 2; public final static byte LEFT = 4; public final static byte RIGHT = 6; public final static byte UP = 8; // 蛇头当前方向 private byte currentDirection; // 用一个链表来存储蛇节点 private Vector worm = new Vector(5, 2); //是否需要更新 private boolean needUpdate; //是否移动后更新 private boolean moveOnNextUpdate; //是否已经吃到食物 private boolean hasEaten; „„ } 同时蛇吃的食物对象数据结构用SnakeFood类来表示如下: public class SnakeFood { //当前食物所在的单元X坐标 private int cellX; //当前食物所在的单元Y坐标 private int cellY; ...... } 下图为类对应图,主要介绍与游戏相关的几个类: SnakeMain:最主要的类,控制所有其它类的运行和销毁。 第 10 页 共 21 页 SnakePit:处理键盘输入事件并实例化Snake类和SnakeFood类的。 Snake:抽象了贪吃蛇的属性和动作。 SnakeFood:抽象了食物的属性和动作。 SnakeScore:用来纪录分数的类。 SnakeLink:抽象了蛇身上的一段,保存了这段的坐标、方向和所有状态。 SnakeException:处理异常类。 图3:类对应图 4系统实现及核心代码 4.1系统实现 首先我将介绍下主要用到的七个类: 一条完整的贪吃蛇是由一段一段组成的。链表中保存的第一个元素是蛇的尾巴段,最后一个元素是蛇的头部段。当蛇运动的时候,它头部段增加一节而尾段减少一节。如果它吃到了食物,尾部段就不减少一节。也就是说,蛇是从头部段开始长的。 吞吃蛇是由一节一节组成的。因为它经常有一些节连成一条直线形成段,所以这是一种相对有效的方法来保存整个蛇。[X,Y]表示段头部的坐标,然后段的头部开始按照方向向后画若干节。(段的头尾和蛇的头尾不是一个概念) 第 11 页 共 21 页 吞吃蛇将会在画面中移动寻找食物。如果它吃到食物它将会长一格。如果它 碰到边界或者吃到自己将Game Over。 下面介绍下Snake类中的几个方法: public void update(Graphics g) 这个函数是更新贪吃蛇状态。每次更新都把头部增加一节,尾部减少一节。 如果它吃到食物尾部段就不减少一节。看起来就像整只蛇长了一节。 // 把吞吃蛇头部增加一格 head = (SnakeLink)worm.lastElement(); head.increaseLength(); // 如果没有吃到食物则尾部减少一格 if (!hasEaten) { SnakeLink tail; tail = (SnakeLink)worm.firstElement(); int tailX = tail.getX(); int tailY = tail.getY(); // 如果尾部块长度为0就删除 tail.decreaseLength(); if (tail.getLength() == 0) { worm.removeElement(tail); } // 尾部减少一格 g.setColor(SnakePit.ERASE_COLOUR); drawLink(g, tailX, tailY, tailX, tailY, 1); } else { // 如果吃到食物就不删除尾部 hasEaten = false; } needUpdate = false; // 确认是否在边界中 if (!SnakePit.isInBounds(head.getEndX(), head.getEndY())) { // 如果不在,就死了 throw new SnakeException("over the edge"); } headX = (byte)head.getEndX(); headY = (byte)head.getEndY(); //贪吃蛇的头部增加一格 g.setColor(SnakePit.DRAW_COLOUR); drawLink(g, headX, headY, headX, headY, 1); // 判断是否吃到自己 for (int i = 0; i < worm.size()-1; i++) { sl = (SnakeLink)worm.elementAt(i); if (sl.contains(headX, headY)) { throw new SnakeException("you ate yourself"); } } void drawLink(Graphics g, int x1, int y1, int x2, int y2, int len) 这个函数用来画蛇的一段,一只完整的蛇是一段一段组成的。 // 把长度转换成像素长度 第 12 页 共 21 页 len *= SnakePit.CELL_SIZE; // (x1 == x2)说明这一段是垂直的 if (x1 == x2) { // 把x1转成像素长度 x1 *= SnakePit.CELL_SIZE; // (y2 < y1)说明是向上运动 if (y2 < y1) { // 就把头、尾左边交换并转成像素 y1 = y2 * SnakePit.CELL_SIZE; } else { // 把y1转成像素 y1 *= SnakePit.CELL_SIZE; } g.fillRect(x1, y1, SnakePit.CELL_SIZE, len); } else { // 这是水平的一段 y1 *= SnakePit.CELL_SIZE; if (x2 < x1) { // 就把头、尾左边交换并转成像素 x1 = x2 * SnakePit.CELL_SIZE; } else { x1 *= SnakePit.CELL_SIZE; } g.fillRect(x1, y1, len, SnakePit.CELL_SIZE); } public void paint(Graphics g) 画出一只完整的吞吃蛇 SnakeLink sl; int x1, x2, y1, y2; int len; for (int i = 0; i < worm.size(); i++) { // 取出每一段,然后画出这一段,连起来就是一只完整的蛇 sl = (SnakeLink)worm.elementAt(i); x1 = sl.getX(); x2 = sl.getEndX(); y1 = sl.getY(); y2 = sl.getEndY(); len = sl.getLength(); drawLink(g, x1, y1, x2, y2, len); }4.2 核心代码 SnakeMain是最主要的类,继承自MIDlet类并实现了CommandListener接口。 protected void startApp() 实现MIDlet父类的方法,当开始程序时首先执行这个函数 // 显示画板 Display.getDisplay(this).setCurrent(theGame); try { // 开始游戏线程 Thread myThread = new Thread(theGame); 第 13 页 共 21 页 myThread.start(); } catch (Error e) { destroyApp(false); notifyDestroyed(); } public void commandAction(Command c, Displayable d) 接受并处理用户输入事件 // 重新开始 if (c == restartCmd) { theGame.restart(); }; // 改变难度等级 if (c == levelCmd) { Item[] levelItem = { new Gauge("Level", true, 9, theGame.getLevel()) }; Form f = new Form("Change Level", levelItem); f.addCommand(OKCmd); f.addCommand(cancelCmd); f.setCommandListener(this); Display.getDisplay(this).setCurrent(f); }; // 离开游戏 if (c == exitCmd) { destroyApp(false); notifyDestroyed(); }; // 开始游戏 if (c == startCmd) { theGame.removeCommand(startCmd); theGame.addCommand(restartCmd); theGame.restart(); }; // 确定 if (c == OKCmd) { Form f = (Form)d; Gauge g = (Gauge)f.get(0); theGame.setLevel(g.getValue()); Display.getDisplay(this).setCurrent(theGame); }; // 取消 if (c == cancelCmd) { Display.getDisplay(this).setCurrent(theGame); }; 第 14 页 共 21 页 5系统测试 5.1测试方法 (1)启动模拟器运行贪吃蛇游戏对各个按键进行检测是否有效。 (2)观察对方向键按下屏幕上蛇的移动变化是否正确。 (3)观察系统设置菜单在相应按键按下后是否正确。 (4)观察在蛇吃到食物,也就是和食物接触时是否增加长度。 (5)观察当蛇移动过程中碰到墙壁或尾巴是否游戏结束。 (6)观察当蛇吃到食物游戏分数是否增加,当游戏难度调节蛇移动速度是否变化以及当游戏技术是否记录最高分。 5.2 测试结果 本游戏只对程序中定义的按键进行响应 (1)本游戏只对程序中所有定义的按键进行一一响应。比如:2,4,6,8。这4个键,分别控制蛇移动的上下左右四个方向。同时,4,6这两个键也可以用来选择菜单,回车键为确定的作用; (2)当按键为方向键时,蛇均会按照正确方向移动。除了这几个键,其他键,均不起作用; (3)当按键为系统菜单按键时,可以正确执行响应方法进行系统设置; (4)当蛇吃到食物身体就会变长; (5)当蛇在移动过程中碰到墙壁或尾部,屏幕上就会出现游戏结束这几个字; (6)当蛇吃到食物分数会增加;游戏默认等级设置的为5级,蛇每吃一个食物分数就增加5分,如果设置游戏等级为9,也就是最高等级,那么蛇没吃一个食物,增加的分数就是9分; (7)当难度改变后,首先改变的就是蛇的移动速度,当然同时分数也会增加。 (8)当游戏运行一段时间后,会出现过关音效,每过一关,游戏等级就增加一级。 第 15 页 共 21 页 : 图4 系统测试图 从图中我们可以看出,本游戏在电脑上的手机模拟器上运行,电脑模拟手机有529K内存的最大内存。图中红线部分就是最大内存位置。当游戏开始运行时,系统会初始化游戏运行环境,电脑上的手机模拟器和真实手机上的界面一致,这个时候会加载一些类,同时创建一些对象,这个过程是一步一步进行,从图中的斜边处可以看出来。然后当游戏运行加载完成后,就进入一个平稳状态。这个过程就是加载游戏打包成的JAR文件的相应过程的内存分配情况。紧接着垃圾回收机制会释放初始化资源,这个过程比较快,这个过程发生在游戏运行起来时,该过程能从图中比较陡的这条竖线看出来。同时垃圾回收机制清理内存后,进入游戏真正需要的内存资源状态,大概在100K左右,当射吃掉一个食物的时候会增加一个食物对象到链表里面,体现在游戏中就是增加蛇身长度,这时就会开放内存空间,同时从上图可以看出,很明显的一个梯度的增加,这个梯度的增加频率跟蛇吃到食物的速度一致。从内存变化图可以看出,该游戏消耗资源比较少,性能上还是比较高效。Wireless Tool Kit提供了许多在运行时监视运行状态的工具。 包括内存状况的检测(手机上的内存空间十分有限,必须时刻关注机载内存是否大于程序所能使用到的最大可能的内存空间),网络状况的检测,运行函数的跟踪等。内存检测器是内存跟踪测试随时间变化的调试器。其中,允许强制垃圾回收(Garbage Collection)。由于在Java语言中,不像许多其他的如C++语言,不需要指定回收函数中待定不使用的资源,资源回收机制将自动清空无效变量占用的空间。在程序运行中也可以调用System类的gc()函数手动收回废弃的内存。 手机内存空间小,所以在程序设计时应该注意以下几点,以尽量减少内存的使用: 第 16 页 共 21 页 (1)尽量缩短命名的长度。在应用程序内,对于所建立的类、接口、方法及 变量名而言,都需要赋予一个识别的名称,所命名的名称每多一个字符 就会在类文件内多产生一个字节,对于一个较复杂的应用程序而言就会 增加为数不小的数据量。所有这些可以借助混淆器来帮助实现。 把所有的程序代码都写为一个类。 (2) (3)在整个开发过程中只使用一个线程。 (4)尽量不使用静态变量。 5.3 测试结论 以上的测试案例是单独进行测试的,还需要进一步的交叉案例测试。通过以上简单测试说明了设计方法的正确性,它已经初步具备了游戏功能,具有良好的检测性能和准确的检测结果。但系统构架和代码设计还需要进一步优化,以提高系统的运行效率,降低所耗的系统资源,为用户提供更好的游戏效果。这本次设计中,我发现一个BUG,始终没有解决,就是在游戏的过程中,会随机出现事物出现在手机墙壁的内侧,蛇就无法吃到里面的事物。我想这可能是因为此次设计上在手机模拟器上来运行的,大的环境是在电脑上,如果把本程序移植在手机上,我想应该不会再出现这样的问题。本次设计也有几个遗憾,一般手机游戏只有1个类,而我有7个类。还有就是没能建立一个游戏排行榜。再有一个原因就是的确是我的能力问题,不能真正解决这些问题。我相信在以后的继续努力学习中,我会进一步完善和改进这些问题。 5.4 程序运行截图 图5:游戏开始界面图图 图6: 服务器运行界面 第 17 页 共 21 页 图7:难度设置图 图8: 菜单选择图 第 18 页 共 21 页 结 论 经过了3个月的忙碌,手机吞吃蛇游戏基本开发完毕。其功能基本符合用户需求。从解决不了细小问题的苦恼到问题最终解决的喜悦,一直伴随着整个设计过程。整个设计过程是不断学习,不断发现问题、分析问题、解决问题的过程。使我受益良多。设计期间有许多的感触、想法、经验,教训,对以后的学习、工作有很大的益处。另外,在使用参考书籍的过程中,有很多的精湛的细节值得认真学习和领悟。这款游戏作为我的毕业设计,是本人目前做过的最有意义的程序, J2ME为一种刚出现这期间对J2ME的学习,使我又回到了初学PASCAL的时候。 仅几年的新技术,国内的参考资料非常少,仅有的几本也停留在简单的介绍阶段。台湾的王森写了本较好的书,给了我很大的帮助,但对设计该游戏来说,仍只够入门。幸运的是,互联网上有那么多无私的人,由Jason Lam著,Deaboway Chou译的电子书《J2ME&Gaming》给了我很大的帮助,作者、译者的辛勤劳动的成果免费放在网上由大家下载,是开源精神的完美体现。我相信在经过我以后的学习,我一定会将我的系统设计得更完善。 参考文献 [1]Joshua Bloce.潘爱民/译. Effective. Java中文版[M].北京:机械工业出版社.2004年7月。 [2]Bruce Eckel.侯捷/译.Java编程思想[M].北京: 机械工业出版社出版社.2005年3月。 [3]王森著.Java手机/PDA程序设计入门[M].北京:电子工业出版社.2005年2月。 [4]James Keogh.潘颖,王磊/译.J2ME开发大全[M].北京:清华大学出版社.2004年2月。 [5]Ian Sommerville.程成等/译.软件工程[M].北京:机械工业出版社.2003年1月。 戏与应用程序设计[M].北京:中国青年出版[6]陈立伟,张克非,黎秀红.精通JAVA手机游 社.2005年5月。 [7]Frand M.Carrano,Janet J.Prichard.韩志宏/译.数据抽象和问题求解—— JAVA语言描述[M].北京:清华大学出版社2005年4月。 [8]袁海燕,王文涛.JAVA实用程序设计100例[M].北京:人民邮电出版社.2005年5月。 [9]耿祥义,张跃平.JAVA2实用教程[M].北京:清华大学出版社.2005年8月。 [10]陈旭东,徐保名.J2ME应用教程[M].北京:北京交通大学出版社.2005年6月。 [11]托普雷.张伶/译.J2ME技术[M].北京:中国电力出版社.2004年2月。 第 19 页 共 21 页 致 谢 在毕业设计和论文编写的过程中,我始终得到了指导老师甘刚老师的大力帮助和关心,多次指出程序及论文不当之处,几易其稿。老师渊博的知识和严谨的治学作风使我受益匪浅,对顺利完成本系统起到了极大的作用。借此向我向导师表示我最诚挚的感谢和祝福。 此外还要感谢辛勤培育我的老师们,及朝夕相处的同学们,他们得关心使我充满动力,他们在系统设计初期给予的帮助,使此系统的开发,有了一个很好的开端~感谢同学们在专业知识上给予我的帮助,因为他们的协助,才得以顺利完成了设计,本人向他们表示深深的谢意~ 最后向在百忙之中评审本文的各位专家、老师表示衷心的感谢~ 作者简介: 姓 名:徐洁 性别:男 出生年月:1983年4月 民族:汉 E-mail :xwh1983302@163.com 第 20 页 共 21 页 声 明 本论文的工作是2007年2月至2007年6月在成都信息工程学院网络工程系完成的。文中除了特别加以标注地方外,不包含他人已经发表或撰写过的研究成果,也不包含为获得成都信息工程学院或其他教学机构的学位或证书而使用过的材料。除非另有说明,本文的工作是原始性工作。 关于学位论文使用权和研究成果知识产权的说明: 本人完全了解成都信息工程学院有关保管使用学位论文的规定,其中包括: (1)学校有权保管并向有关部门递交学位论文的原件与复印件。 (2)学校可以采用影印、缩印或其他复制方式保存学位论文。 (3)学校可以学术交流为目的复制、赠送和交换学位论文。 (4)学校可允许学位论文被查阅或借阅。 (5)学校可以公布学位论文的全部或部分内容(保密学位论文在解密后遵守此规定)。 除非另有科研和其他法律文书的制约,本论文的科研成果属于成都信息工程学院。 特此声明~ 作者签名: 年 月 日 第 21 页 共 21 页 sounds that were a lot like laughter. 'You think it's funny, huh?' Weary inquired. He walked around to Billy's back. Billy's jacket and shirt and undershirt had been hauled up around his shoulders by the violence, so his back was naked. There, inches from the tips of Weary's combat boots, were the pitiful buttons of Billy's spine. Weary drew back his right boot, aimed a kick at the spine, at the tube which had so many of Billy's important wires in it. Weary was going to break that tube. But then Weary saw that he had an audience. Five German soldiers and a police dog on a leash were looking down into the bed of the creek. The soldiers' blue eyes were filled with bleary civilian curiosity as to why one American would try to murder another one so far from home, and why the victim should laugh. Three The Germans and the dog were engaged in a military operation which had an amusingly self-explanatory name, a human enterprise which is seldom described in detail, whose name alone, when reported as news or history, gives many war enthusiasts a sort of post-coital satisfaction. It is, in the imagination of combat's fans, the divinely listless loveplay that follows the orgasm of victory. It is called 'mopping up.' The dog, who had sounded so ferocious in the winter distances, was a female German shepherd. She was shivering. Her tail was between her legs. She had been borrowed that morning from a farmer. She had never been to war before. She had no idea what game was being played. Her mine was Princess. Two of the Germans were boys in their early teens. Two were ramshackle old me droolers as toothless as carp. They were irregulars, armed and clothed fragmentarily with junk taken from real soldiers who were newly dead. So it goes. They were farmers from just across the German border, not far away. Their commanander was a middle-aged corporal-red-eyed., scrawny, tough as dried beef, sick of war. He had been wounded four times-and patched up, and sent back to war. He was a very good soldier-about to quit, about to find somebody to surrender to. His bandy legs were thrust into golden cavalry boots which he had taken from a dead Hungarian colonel on the Russian front. So it goes. Those boots were almost all he owned in this world. They were his home. An anecdote: One time a recruit was watching him bone and wax those golden boots, and he held one up to the recruit and said, 'If you look in there deeply enough, you'll see Adam and Eve.' Billy Pilgrim had not heard this anecdote. But, lying on the black ice there, Billy stared into the patina of the corporal's boots, saw Adam and Eve in the golden depths. They were naked. They were so innocent, so vulnerable, so eager to behave decently. Billy Pilgrim loved them. Next to the golden boots were a pair of feet which were swaddled in rags. They were crisscrossed by canvas straps, were shod with hinged wooden clogs. Billy looked up at the face that went with the clogs. It was the face of a blond angel of fifteen-year-old boy. The boy was as beautiful as Eve. Billy was helped to his feet by the lovely boy, by the heavenly androgyne. And the others came forward to dust the snow off Billy., and then they searched him for weapons. He didn't have any. The most dangerous thing they found on his person was a two-inch pencil stub. Three inoffensive bangs came from far away. They came from German rifles. The two scouts who had ditched Billy and Weary had just been shot. They had been lying in ambush for Germans. They had been discovered and shot from behind. Now they were dying in the snow, feeling nothing, turning the snow to the color of raspberry sherbet. So it goes. So Roland Weary was the last of the Three Musketeers. And Weary, bug-eyed with terror, was being disarmed. The corporal gave Weary's pistol to the pretty boy. He marveled at Weary's cruel trench knife, said in German that Weary would no doubt like to use the knife on him, to tear his face off with the spiked knuckles, to stick the blade into his belly or throat. He spoke no English, and Billy and Weary understood no German. 'Nice playthings you have, the corporal told Weary, and he handed the knife to an old man. 'Isn't that a pretty thing? Hmmm? He tore open Weary's overcoat and blouse. Brass buttons flew like popcorn. The corporal reached into Weary's gaping bosom as though he meant to tear out his pounding heart, but he brought out Weary's bulletproof Bible instead. A bullet-proof Bible is a Bible small enough to be slipped into a soldier's breast pocket, over his heart. It is sheathed in steel. The corporal found the dirty picture of the woman and the pony in Weary's hip pocket. 'What a lucky pony, eh?' he said. "Hmmmm? Hmmmm? Don't you wish you were that pony?' He handed the picture to the other old man. 'Spoils of war! It's all yours, you lucky lad.' Then he made Weary sit down in the snow and take off his combat boots, which he gave to the beautiful boy. He gave Weary, the boy's clogs. So Weary and Billy were both without decent military footwear now' and they had to walk for miles and miles, with Weary's clogs clacking, with Billy bobbing up-and-down, up-and-down, crashing into Weary from time to time. 'Excuse me,' Billy would say, or 'I beg your pardon.' They were brought at last to a stone cottage at a fork in the road. It was a collecting point for prisoners of war. Billy and Weary were taken inside, where it was warm and smoky. There vas a fire sizzling and popping in the fireplace. The fuel was furniture. There were about twenty other Americans in there, sitting on the floor with their backs to the wall, staring into the flames-thinking whatever there was to think, which was zero. 第 22 页 共 21 页 Nobody talked. Nobody had any good war stories to tell. Billy and Weary found places for themselves, and Billy went to sleep with his head on the shoulder of an unprotesting captain. The captain was a chaplain. He was a rabbi. He had been shot through the hand. Billy traveled in time, opened his eyes, found himself staring into the glass eyes of a jade green mechanical owl. The owl was hanging upside down from a rod of stainless steel. The owl was Billy's optometer in his office in Ilium. An optometer is an instrument for measuring refractive errors in eyes-in order that corrective lenses may be prescribed. Billy had fallen asleep while examining a female patient who was m a chair on the other side of the owl. He had fallen asleep at work before. It had been funny at first. Now Billy was starting to get worried about it, about his mind in general. He tried to remember how old he was, couldn't. He tried to remember what year it was. He couldn't remember that, either. 'Doctor,' said the patient tentatively. 'Hm?' he said. 'You're so quiet.' 'Sorry.' 'You were talking away there-and then you got so quiet' 'Um.' 'You see something terrible?' 'Terrible?' 'Some disease in my anslated by David Lewis The elderly man stroked the dogpillar's head. "This fellow here, I wonder what he was called before he became a dogpillar." "No calling a dogpillar by its original name," I said. "Isn't that a strange law?" The man gave me a quick glance, then replied casually. "Didn't they just extend the laws concerning people to dogs? That's why they lose their names when they become dogpillars." He nodded while scratching the dogpillar's jaw. "Not only the old names, but you can't give them new names, either. That's because there are no proper nouns for plants." Why, of course, I thought. He Looked at my envelope with MANUSCRIPT ENCLOSED written on it. "Excuse me," he said. "Are you a writer?" I was a little embarrassed. "Well. yes. Just trivial little things." "So that's it." After looking at me closely, the man returned to stroking the dogpillar's head. "I also used to write things." He managed to suppress a smile. "How many years is it now since I stopped writing? It feels like a long time." I stared at the man's profile. Now that he said so, it was a face I seemed to have seen somewhere before. I started to ask his name, hesitated, and fell silent. The elderly man said abruptly, "It's become a hard world to write in." I lowered my eyes, ashamed of myself, who still continued to write in such a world. "It certainly has..." The man apologized in a bit of a flurry discerning my sudden depression. "That was rude. I'm not criticizing you. I'm the one who should feel ashamed." "No," I told him, after looking quickly around us, "I can't give up writing because I haven't the courage. Giving up writing! Why, after all, that would be a gesture against society." The elderly man continued stroking the dogpillar. After a long while he spoke. "It's painful, suddenly giving up writing. Now that it's come to this, I would have been better off if I'd gone on boldly writing social criticism and had been arrested. There are even times when I think that. But I was just a dilettante, never knowing poverty, craving peaceful dreams. I wanted to live a comfortable life. As a person strong in self- respect, I couldn't endure being exposed to the eyes of the world, ridiculed. So I quit writing, A sorry tale." He smiled and shook his head. "No no, let's not talk about it. You never know where someone might be listening." "You're right." I changed the subject. "Do you live near here?" "Do you know the beauty parlor on the main street? You turn in there. My name is Hiyama." He nodded at me. "Come on over sometime. There's no one home but my wife." "Thank you 第 23 页 共 21 页 very much." I gave him my own name. I didn't remember any writer named Hiyama. No doubt he wrote under a pen name. I had no intention of visiting his house. This is a world where even two or three writers getting together is considered illegal assembly. "It's time for the mail truck to come." Talking pains to look at my watch, I stood up. "I'm afraid I'd better go," I said. He turned a sadly smiling face toward me and bowed slightly. After stroking the dogpillar's head a little, I left the park. Standing Woman(2)--- I came out on the main street, there were a lot of cars on the road but few pedestrians. A cattree about thirty to forty centimeters high was planted next to the sidewalk. Sometimes I come across a catpillar that has just been planted and still hasn't become a cattree. New catpillars look at my face and meow or cry, but the ones where all four limbs planted in the ground have vegetized, with their greenish faces stiffly set and their eyes shut tight, only move their ears now and then. Then there are catpillars that grow branches from their bodies and put out handfuls of leaves. The mental condition of there seems to be completely vegetized •| they don't even move their ears. Even if you can still make out a cat's face, it may be better to call these cattrees. Maybe. I thought, it's better to make dogs into dogpillars. When their food runs out, they get vicious and even turn on people. But why did they have to turn cats into catpillars? Too many strays? To improve the food situation even a little? Or perhaps for the greening of the city ... Next to the big hospital on the corner where the roads cross are two mantrees, and ranged alongside these trees is a manpillar. This manpillar wears a postman's uniform, and you can't tell how far its legs have vegetized because of its trousers. It is male, thirty-five or thirty-six years old, tall, with a bit of a stoop. I approached him and held out my envelope as always. "Registered mail, special delivery, please." The manpillar, nodding silently, accepted the envelope and took stamps and a registered mail slip from his pocket. I looked around quickly after paying the postage. There was no one else there. I decided to try speaking to him. I had been giving him mail every three days, but I still hadn't had an opportunity chance for a leisurely talk. "What did you do?" I asked in a low voice. The manpillar looked at me in surprise. Then, after running his eyes around the area, he answered with a sour look, "Won't do to go saying unnecessary things to me. Even me, I'm not supposed to answer." ways been, the wonted way of things. Spitz was a practiced fighter. From Spitzbergen through the Arctic, and across Canada and the Barrens, he had held his own with all manner of dogs and achieved to mastery over them. Bitter rage was his, but never blind rage. In passion to rend and destroy, he never forgot that his enemy was in like passion to rend and destroy. He never rushed till he was prepared to receive a rush; never attacked till he had first defended that attack. In vain Buck strove to sink his teeth in the neck of the big white dog. Wherever his fangs struck for the softer flesh, they were countered by the fangs of Spitz. Fang clashed fang, and lips were cut and bleeding, but Buck could not penetrate his enemy's guard. Then he warmed up and enveloped Spitz in a whirlwind of rushes. Time and time again he tried for the snow-white throat, where life bubbled near to the surface, and each time and every time Spitz slashed him and got away. Then Buck took to rushing, as though for the throat, when, suddenly drawing back his head and curving in from the side, he would drive his shoulder at the shoulder of Spitz, as a ram by which to overthrow him. But instead, Buck's shoulder was slashed down each time as Spitz leaped lightly away. Spitz was untouched, while Buck was streaming with blood and panting hard. The fight was growing desperate. And all the while the silent and wolfish circle waited to finish off whichever dog went down. As Buck grew winded, Spitz took to rushing, and he kept him staggering for footing. Once Buck went over, and the whole circle of sixty dogs started up; but he recovered himself, almost in mid air, and the circle sank down again and waited. But Buck possessed a quality that made for greatness--imagination. He fought by instinct, but he could fight by head as well he rushed, as though attempting the old shoulder trick, but at the last instant swept low to the snow and in. His teeth closed on Spitz's left fore leg. There was a crunch of breaking bone, and the white dog faced him on three legs. Thrice he tried to knock him over, then repeated the trick and broke the right fore leg. Despite the pain and helplessness, Spitz struggled madly to keep up. He saw the silent circle, with gleaming eyes, lolling tongues, and silvery breaths drifting upward, closing in upon him as he had seen similar circles close in upon beaten antagonists in the past. Only this time he was the one who was beaten. There was no hope for him. Buck was inexorable. Mercy was a thing reserved for gentler climes. He maneuvered for the final rush. The circle had tightened till he could feel the breaths of the huskies on his flanks. He could see them, beyond Spitz and to either side, half-crouching for the spring, their eyes fixed upon him. A pause seemed to fall. Every animal was motionless as though turned to stone. Only Spitz quivered and bristled as he staggered back and forth, snarling with horrible menace, as though to frighten off impending death. Then Buck sprang in and out; but while he was in, shoulder had at last squarely met shoulder. The dark circle became a dot on the moon flooded snow as Spitz disappeared from view. Buck stood and looked on, the successful champion, the dominant primordial beast who had made his 第 24 页 共 21 页 kill and found it good. away. At the Pelly one morning, as they were harnessing up, dolly, who had never been conspicuous for anything, went suddenly mad. She announced her condition by a long, heart-breaking wolf howl that sent every dog bristling with fear, then sprang straight for Buck. He had never seen a dog go mad, nor did he have any reason to fear madness; yet he knew that here was horror, and fled away from it in a panic. Straight away he raced, with Dolly, panting and frothing, one leap behind; nor could she gain on him, so great was his terror, nor could he leave her, so great was her madness. He plunged through the wooded breast of the island, flew down to the lower end, crossed a back channel filled with rough ice to another island, gained a third island, curved back to the main river, and in desperation started to cross it. And all the time, though he did not look, he could hear her snarling just one leap behind. Francois called to him a quarter of a mile away and he doubled back, still one leap ahead, gasping painfully for air and putting all his faith in that Francois would save him. the dog-driver held the axe poised in his hand, and as Buck shot past him the axe crashed down upon mad Dolly's head. Buck staggered over against the sled, exhausted, sobbing for breath, helpless. This was Spitz's opportunity. He sprang upon Buck, and twice his teeth sank into his unresisting foe and ripped and tore the flesh to the bone. Then Francois' lash descended, and Buck had the satisfaction of watching Spitz receive the worst whipping as yet administered to any of the team. "One devil, dat Spitz," remarked Perrault. "Some dam day him kill dat Buck." "Dat Buck two devils," was Francois's rejoinder. "All de time I watch dat Buck I know for sure. Lissen: some dam fine day him get mad like hell and den him chew dat Spitz all up and spit him out on de snow. Sure, I know." From then on it was war between them. Spitz, as lead-dog and acknowledged master of the team, felt his supremacy threatened by this strange Southland dog.F And strange Buck was to him, for of the many Southland dogs he had known, not one had shown up worthily in camp and on trail. They were all too soft, dying under the toil, the frost, and starvation. Buck was the exception. He alone endured and prospered, matching the husky in strength, savagery, and cunning.E Then he was a masterful dog, and what made him dangerous was the fact that the club of the man in the red sweater had knocked all blind pluck and rashness out of his desire for mastery. He was preeminently cunning, and could bide his time with a patience that was nothing less than primitive. PART 3 Mulan: Okay, okay, how 'bout this? Ahem, [in her manly voice] excuandanother man picking out dirt from between his toes with chopsticks] Beautifulisn't it? Mulan [making a face of disgust and continuing to walk]: They're disgusting. Mushu: No, they're men. And you're going to have to act just like them, sopay attention. [Mulan stops and watches Yao, Ling, Chien-Po and Tattoo Soldier] Tattoo Soldier [showing the dragon tattoo on his chest and belly]: Look, thistattoo will protect me from harm. [Yao thi Shang: What's your name? Mulan [stumbling]: Ahh, I, uhhh, I, uh-- Chi Fu [stepping into Mulan's face]: Your commanding officer just asked you a question. Mulan: Uhh, I've got a name. Huh. And it's a boys name too. Mushu [from the back of Mulan]: Ling, How 'bout Ling? Mulan [to Mushu motioning with her head to Ling]: His name's Ling. Shang: I didn't ask for his name. I asked for yours. Mushu: Try, uh, ahh, Chu! Mulan: Ah Chu. Shang: Ah Chu? Mushu: Gesundheit. He He, I kill myself. Mulan [whispering over her shoulder]: Mushu. Shang: Mushu? Mulan: No. Shang: Then what is it! Mushu: Ping! Ping was my best friend growing up! 第 25 页 共 21 页 Mulan: It's Ping. Shang: Ping. Mushu: Of course Ping DID steal my gir-[Mulan reaches back and grabs holds Mushu's mouth together] Mulan: Yes, my name is Ping. Shang: Let me see your conscription notice. [Takes the notice from Mulan] Fa Zhou, *the* Fa Zhou? Chi Fu: I didn't know Fa Zhou had a son. Mulan: Um, he...doesn't talk about me much. [Mulan tries to hawk up a loogie and spit but the saliva just runs from her mouth. Therecruits laugh] Chi Fu: I can see why, the boy's an absolute lunatic. Shang [to the recruits]: Okay gentlemen, thanks to your new friend Ping, you'll spend tonight picking up every single grain of rice. Andtomorrow, the real work begins. [All recruits growl at Mulan] Mushu [Popping out the front of Mulan's armor]: You know, we have to work on your people skills. [Cut to Mulan sleeping in her tent. Mushu winds up Cri-Kee's wings. Cri-Kee rings like an alarm clock] S - GLAUCON AND thus, Glaucon, after the argument has gone a weary way, the true and the false philosophers have at length appeared in view. I do not think, he said, that the way could have been shortened. I suppose not, I said; and yet I believe that we might have had a better view of both of them if the discussion could have been confined to this one subject and if there were not many other questions awaiting us, which he who desires to see in what respect the life of the just differs from that of the unjust must consider. And what is the next question? he asked. Surely, I said, the one which follows next in order. Inasmuch as philosophers only are able to grasp the eternal and unchangeable, and those who wander in the region of the many and variable are not philosophers, I must ask you which of the two classes should be the rulers of our State? And how can we rightly answer that question? Whichever of the two are best able to guard the laws and institutions of our State --let them be our guardians. Very good. Neither, I said, can there be any question that the guardian who is to keep anything should have eyes rather than no eyes? There can be no question of that. And are not those who are verily and indeed wanting in the knowledge of the true being of each thing, and who have in their souls no clear pattern, and are unable as with a painter's eye to look at the absolute truth and to that original to repair, and having perfect vision of the other world to order the laws about beauty, goodness, justice in this, if not already ordered, and to guard and preserve the order of them --are not such persons, I ask, simply blind? Truly, he replied, they are much in that condition. And shall they be our guardians when there are others who, besides being their equals in experience and falling short of them in no particular of virtue, also know the very truth of each thing? There can be no reason, he said, for rejecting those who have this greatest of all great qualities; they must always have the first place unless they fail in some other respect. Suppose then, I said, that we determine how far they can unite this and the other excellences. By all means. In the first place, as we began by observing, the nature of the philosopher has to be ascertained. We must come to an understanding about him, and, when we have done so, then, if I am not mistaken, we shall also acknowledge that such an union of qualities is possible, and that those in whom they are united, and those only, should be rulers in the State. What do you mean? Let us suppose that philosophical minds always love knowledge of a sort which shows them the eternal nature not varying from generation and corruption. Agreed. And further, I said, let us agree that they are lovers of all true being; there is no part whether greater or less, or more or less honourable, which they are willing to renounce; as we said before of the lover and the man of ambition. True. And if they are to be what we were describing, is there not another quality which they should also possess? What quality? Truthfulness: they will never intentionally receive into their mind falsehood, which is their detestation, and they will love the truth. Yes, that may be safely affirmed of them. 第 26 页 共 21 页 'May be,' my friend, I replied, is not the word; say rather 'must be affirmed:' for he whose nature is amorous of anything cannot help loving all that belongs or is akin to the object of his affections. Right, he said. And is there anything more akin to wisdom than truth? How can there be? Can the same nature be a lover of wisdom and a lover of falsehood? Never. The true lover of learning then must from his earliest youth, as far as in him lies, desire all truth? Assuredly. But then again, as we know by experience, he whose desires are strong in one direction will have them weaker in others; they will be like a stream which has been drawn off into another channel. True. He whose desires are drawn towards knowledge in every form will be absorbed in the pleasures of the soul, and will hardly feel bodily pleasure --I mean, if he be a true philosopher and not a sham one. That is most certain. Such an one is sure to be temperate and the reverse of covetous; for the motives which make another man desirous of having and spending, have no place in his character. Very true. Another criterion of the philosophical nature has also to be considered. What is that? There should be no secret corner of illiberality; nothing can more antagonistic than meanness to a soul which is ever longing after the whole of things both divine and human. Most true, he replied. Then how can he who has magnificence of mind and is the spectator of all time and all existence, think much of human life? He cannot. Or can such an one account death fearful? 第 27 页 共 21 页
/
本文档为【手机吞吃蛇游戏的设计与开发】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索