推荐星级:
  • 1
  • 2
  • 3
  • 4
  • 5

基于Python的飞机大战游戏设计

更新时间:2019-12-21 12:53:36 大小:2M 上传用户:songhuahua查看TA发布的资源 标签:python 下载积分:1分 评价赚积分 (如何评价?) 收藏 评论(0) 举报

资料介绍

基于Python软件的面向对象编程思想设计飞机大战游戏,玩家操作飞机发射子弹,通过左右移动来躲避子弹;敌机位于屏幕顶部左右匀速移动,并且随机向玩家飞机发射子弹。实践表明,该游戏操作简单灵活,具有趣味性。


部分文件列表

文件名 大小
基于Python的飞机大战游戏设计.pdf 2M

部分页面预览

(完整内容请下载后查看)
23  
1
卷 第  
Vol. 23 No. 1  
Mar. 2019  
扬 州 职 业 大 学 学 报  
Journal of Yangzhou Polytechnic College  
2019  
3
Python  
基于  
飞机战游戏计  
(
江苏职业江苏 扬州  
225000)  
:
于  
Python , ,  
计飞游戏 玩发射通过左右移  
; ,  
动来弹 敌屏幕顶左右速移且随发射游戏操单  
性  
: Python;  
; Pygame  
关键词  
中图分类号  
游戏  
: TP 311. 52  
: A  
: 1008 - 3693( 2019) 01 - 0035 - 05  
文章编号  
文献标识码  
Design of Aircraft War Game Based on Python  
Qu Su  
( Tourism Voacational College of JiangsuYangzhou 225000China)  
Abstract: This paper introduces the design of aircraft war game based on Python object-oriented programming.  
Operating the aircraftplayers can fire bulletscan move left and right to avoid bulletswhile the enemy air-  
craft at the top of the screen moves from left to right at a constant speed and randomly shoots players. Practice  
shows that the game is simple and flexible with great fun.  
Key words: Python; aircraft war game; Pygame  
Python  
涉及到  
是一学的言  
1
飞机战游戏总计  
Web  
系统理  
1. 1  
是一  
则  
如下  
空  
: ( 1)  
软  
用  
Python  
; ( 2)  
机  
懂  
Python ,  
的  
戏  
于  
; ( 3) 。 、  
要求 的  
;
规则成同使  
是一中用  
样都图  
1]  
Pygame  
; 、  
在  
片需助  
示  
,  
的位标标窗  
是一的  
( 00) x  
1. 2  
为  
值  
计  
y 。  
的游戏  
系统验  
这个标系 是  
标直界  
: 、  
移  
化  
: 2018 - 10 - 28  
收稿日期  
:
作者简介  
( 1982—) , , ,   
旅游职业学院旅游信息学院教授 士  
23  
扬州职业大学学报  
36  
; ( ) ;  
动 显敌  
,  
的位左右能 可以  
x ,  
坐  
弹  
1. 3  
1. 3. 1  
pygame  
x
x  
大 的值  
作  
pygame  
Python File,  
plane.  
添加  
是一的  
Python  
模块  
个  
plane. py  
为  
Python  
入  
pygame  
一  
块  
的游  
PyCharm Python  
HeroPlane。  
块允在  
序  
表示类  
发  
为  
displaymove left  
效  
move right  
中  
display  
认  
包含像  
pygame  
方  
; moveleft  
的位机  
; moveright  
让飞移  
start  
块  
让飞动  
数  
PyCharm  
pygame ,  
导  
加  
中  
while  
pygame  
, ,  
证  
true  
语句根据的  
块  
向  
1. 3. 2  
搭建游戏界面  
“ ” A,  
机  
作  
“ ” D,  
的  
。  
中的为了的  
动  
片  
2. 2  
2. 2. 1  
发射弹  
入  
pygame  
就能块  
显示子弹  
中的法  
机要子  
1. 3. 3  
检查键盘的输入  
子  
要  
,  
左右格  
使击  
的  
Python  
、  
交  
部  
由  
pygame event  
块  
Python Filebulletbul-  
在  
个  
let. py  
event  
列表形式件  
制  
, ,  
入模表示弹  
get  
鼠  
过  
生的使用  
event. type(  
如下  
:
for  
class Bullet( object) :  
环遍列表 取  
def init ( selfxyscreen) :  
)
对  
与  
self. x = x + 40  
event. type  
Quit,  
使用  
果  
为  
self. y = y - 20  
标点时就要退  
self. screen = screen  
self. iamge = pygame. image. load( /feiji/bullet - 3.  
;
果  
event. type  
Keydown,  
用  
gif) . convert( )  
def. display( self) :  
self. screen. blit( self. iamge( self. xself. y) )  
使时就要明确的是键  
while  
图  
, ,  
比  
如下  
:
heroPlane. launch bullet( )  
,  
行更新  
, ,  
部  
, ,  
再  
,  
的子时 无哪  
新  
的子其顶部  
2. 2. 2  
次  
2
飞机战游戏功能实现  
子弹移动  
while  
dis-  
2. 1  
向  
次  
机 可根据飞  
play  
。  
再次幕  
名称屏  
。  
速度无法捕捉用  

全部评论(0)

暂无评论