基于51单片机模拟射击类游戏大学王凯(抄袭必纠)摘要电子游戏机,又俗称电玩,电动,不同于电脑。
自从问世以来,在全球围吸引了无数人的热潮,在每个国家都能找到众多的游戏发烧友,它无疑是当今社会上炙手可热的产品,基于这个广大的应用前景,本文着手研究电子模拟射击训练游戏。
本文主要通过使用51单片机来模拟简单的射击游戏。
在像素为160*128的LCD显示屏上显示模拟的手枪,并且可以用按键控制手枪的上下移动以及射出子弹,判断子弹是否击中移动的目标,最后统计得分显示结果。
当目标被击中时,蜂鸣器就会发出声音,并且设置有重新开始按键,即得分清零,子弹恢复初始值。
本设计通过K1、K2、K3、K4四个按键对游戏进行控制,分别为“向上”键,“向下”键,“发射”键,“子弹复位”键。
通过控制上下键使射击器与射击目标保持同一水平线上,然后开始射击,此时蜂鸣器发出发射音效,如射中即可获得一分得分,否则得分不变。
当子弹弹数为0时,按“子弹复位”键使游戏中的子弹数目恢复,就重新开始新的游戏。
本课题是基于单片机应用技术和LCD液晶显示屏的广泛应用而提出的,本课题所做的设计是以AT89S52单片机结合JM160128A显示器,通过proteus画图软件和keil的C语言编程软件,达到实现模拟射击游戏的目的。
通过将AT89S52单片机与JM160128A LCD结合应用,在仿真软件和硬件上都能很好地模拟常见的简单射击游戏,实现预期目标。
在游戏运行过程中,能够通过上下键移动枪支,射击目标,并能够实现上弹复位的目的。
这对于更深层次的单片机开发应用有着重要的意义。
关键词:AT89S52单片机,LCD液晶显示屏,C语言,射击游戏AbstractElectronic games, also known as electric toys (video games, electric), separated from the home computer. Since the advent of a sensation around the world, we can find a group of ingenious enthusiasts on every foot in the Earth's. It isundoubtedly one of today's most computer products of the customers, based on the vast number of potential applications, the paper started studying electronic analog shooting training game.This paper is mainly using combination design which includes MCU AT89S52 and 160*128LCD to simulate simple shooting training game ,displaying the simulate pistol’s graphics in pixels for 160*128LCD and through pressing the button to control pistol and to move up and down and then decide whether it has hit the target ,then statistic scores and display it .every time when hitting the target ,buzzer will issue hit sound ,otherwise restart key works .By this design, there are K1, K2, K3, K4 four control buttons on the game, namely "up" key, "down" key, the "transmit" button, "bullet Reset" button. By controlling the up and down keys to keep shooting target and pistol on the same level, then start shooting target, at the same time , the buzzer sounds emitted, the score will add one if you shot, otherwise the score unchanged. When the bullet shells is zero, press the "bullet Reset" key to restore the number of bullets in the game, the game can start again, a new round of challenges begin. This paper proposed is based on the wide range of applications of single-chip technology and JM160128A.In order to simulate shooting training game, AT89S52 single-chip is served as the core , combined JM160128A display, then together with ISIS_7_Professional and Micro-controller Development kit,also named KEIL ,to achieve the goal of simulating shooting training game.By combining AT89S52 MCU with JM160128A LCD applications,we can achieve the desired objectives and can can well simulate common simple shooting game both in software and hardware. In the course of the game running,we can shoot target by moving guns with up and down keys and have the ability to achieve the purpose of the missile reset. This has very real implications for the development of SCM deeper applications.Keywords:AT89S52MCU, LCD,C language ,shooting game目录第一章绪论 (3)1.1 系统设计背景及意义 (3)1.2 国外研究现状 (3)1.3 系统设计任务 (3)1.4 本章小结 (3)第二章射击训练游戏系统方案设计 (3)2.1 系统工作原理 (3)2.2 系统组成框图 (3)2.3 硬件的选型 (3)2.3.1.单片机概述 (3)2.3.2.单片机最小系统 (3)2.3.3.单片机选型 (3)2.3.4.LCD的选型 (3)2.4 本章小结 (3)第三章射击训练游戏器件介绍 (3)3.1 AT89S52单片机 (3)3.2 PG160128A (3)3.3 74LS20与非门 (3)3.4 74HC04 (3)第四章射击训练游戏硬件电路设计 (3)4.1 晶振和复位电路 (3)4.2 按键与单片机接口电路 (3)4.3 单片机与LCD显示屏接口电路 (3)第五章射击训练游戏系统软件设计与仿真 (3)5.1 系统的软件控制流程 (3)5.2 主要功能模块软件设计 (3)5.2.1 开机游戏封面图像 (3)5.2.2 枪支图像 (3)5.2.3 按键子程序流程图 (3)5.2.4 汉字显示主程序 (3)5.3 系统的软件仿真 (3)5.3.1 仿真软件 (3)5.3.2 软件仿真过程 (3)5.3.3 软件仿真结果 (3)第六章实物制作与调试 (3)6.1 所需原件 (3)6.2 焊接 (3)6.3 程序的烧录 (3)第七章总结 (3)致........................................................................................... 错误!未定义书签。
参考文献 . (3)第一章绪论1.1 系统设计背景及意义1988年,随着自动售货机的面试,一个叫斯托维克的德国人根据其原理设计了一种叫做“自动产蛋机”的机器,自此游戏机在世界围风行起来。
在世界围,无论是大城市还是小村庄,无论是在国还是在国外,每时每刻都在进行着这样的“奋斗”。
随着时间的推移,人们的生活已经离不开游戏机了,在大街小巷能看见各种各样的游戏机。
然而,游戏机狂潮为什么能够席卷全世界呢?从游戏机的发展历史我们不难看出,科学技术的快速进步在游戏机发展过程中起到了至关重要的作用。
然而,科学技术水平的快速发展并不是游戏机在全世界风行的唯一因素。
随着我们对终端设备的开发,使得娱乐终端的游戏机同时也获得了很大程度的发展。
这也是导致游戏机全世界风靡的一个重要因素。
因此我们对于游戏机的研究具有很重要的意义,这也是我们对于本课题研究的背景和意义。
用51单片机设计一个游戏,与现如今那些大型游戏和手机游戏不同,也与单片机控制的其他程序有所区别,因为它要求游戏编写者对单片机的构造原理、工作的模式、指令系统和数据在存中的分配以及信息的传递都要有着很深刻的理解,特别是游戏运行的时候对外部按键中断的处理以及各个子程序调用的先后顺序,代码的复杂程度也比一般的单片机程序要复杂很多。
如果我们编写的游戏程序能够如预期一样的稳定运行,我们将对单片机有着更深的理解,对编写游戏的复杂程度有更切身的体会。
同时也将大大提高我们的编程能力以及逻辑思维能力,也将再一次的体会到C语言的适用性,高效性和易移植性,也将使我们对C语言有更深刻的理解。
1.2 国外研究现状目前国的游戏公司已经发展到了几百家的规模,市场上运营的游戏亦达到了250多款,但是与欧美、国等科技强国的游戏发展程度还存在一定的差距。