上传文件至 ''
This commit is contained in:
parent
cf0d272de7
commit
809d307ebc
36
l.py
36
l.py
|
@ -22,33 +22,9 @@ class Bullet(object):
|
|||
return True #返回true正确
|
||||
else:
|
||||
return False #返回false错误
|
||||
#玩家飞机类
|
||||
class Aircraft_obj(object):
|
||||
#构造方法,初始化飞机对象的属性
|
||||
def __init__(self, screen_temp):
|
||||
self.x = 190 #飞起起始x坐标
|
||||
self.y = 708 #飞机起始y坐标
|
||||
self.screen = screen_temp #窗口
|
||||
self.image = pygame.image.load("C:/work/youxi/1.png") #创建一个飞机图片
|
||||
self.bullet_list = [] #存储发射出去的子弹对象
|
||||
#显示飞机图片的方法(这里包括了显示子弹的图片)
|
||||
def display(self):
|
||||
self.screen.blit(self.image, (self.x, self.y)) #显示飞机图片
|
||||
#显示飞机发射的所有子弹
|
||||
for bullet in self.bullet_list:
|
||||
bullet.display() #显示子弹
|
||||
bullet.move() #移动子弹
|
||||
if bullet.judge(): #判断子弹是否越界
|
||||
self.bullet_list.remove(bullet) #删除子弹
|
||||
#飞机左移方法
|
||||
def move_left(self):
|
||||
if self.x < 10: #x坐标小于10(移动距离)
|
||||
pass #不做任何事
|
||||
else:
|
||||
self.x -= 10 #X坐标自减少10
|
||||
#飞机右移方法
|
||||
def move_right(self):
|
||||
if self.x > 480-100-10: #X坐标大于(窗口宽度-飞机宽度-移动距离)的值
|
||||
pass #不做任何事
|
||||
else:
|
||||
self.x += 10 #坐标自增加10
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue