| 
                         实现飞机类,完成飞机的主要操作。飞机的操作包括:飞机位置、飞机子弹、发射子弹等。 
- # 飞机类,继承DestroyAnimationMixin, 方便使用显示自毁动画的函数 
 - class Plan(DestroyAnimationMixin): 
 -     def __init__(self, image_path=os.path.join(source_dir,'plan.png'), background_size=(480, 700)): 
 -         ''' 
 -         :param image_path: 飞机图片地址 
 -         :param background_size: 游戏窗口大小 
 -         ''' 
 -         self.background_size = background_size 
 -         self.image = pygame.image.load(image_path).convert_alpha() 
 -         self.image_size = self.image.get_size() 
 -         self.position = [(background_size[0]-self.image_size[0]) / 2, 500] 
 -         # 飞机每次移动的距离 
 -         self.every_time_move_distance = 0.5 
 -         # 飞机的子弹 
 -         self.bullets = [] 
 -         # destroy association attributes, 自毁相关属性 
 -         # 开始自毁 
 -         self.start_destroy = False 
 -         # 自毁结束 
 -         self.destroyed = False 
 -         # 自毁图片 
 -         self.destroy_images = ['me_destroy_1.png', 'me_destroy_2.png', 'me_destroy_3.png', 'me_destroy_4.png'] 
 -         # 自毁图片位置 
 -         self.destroy_image_position = 0 
 -         # 距离上次绘制图像到现在的时间 
 -         self.time_passed = 0 
 -  
 -     def update(self, direction): 
 -         ''' 
 -         更新飞机位置 
 -         :param direction: 飞机移动方向 
 -         ''' 
 -         pass 
 -  
 -     def shut(self, image_path=os.path.join(source_dir,'bullet.png')): 
 -         ''' 
 -         飞机发射子弹 
 -         :param image_path: 子弹图片 
 -         ''' 
 -         pass 
 -  
 -     def draw_bullets(self, time_passed, screen): 
 -         ''' 
 -         绘制飞机的所有子弹 
 -         :param time_passed: 距离上次绘制图像到现在的时间 
 -         :param screen: 绘制到哪一个窗口中 
 -         ''' 
 -         pass 
 
  
                          (编辑:52站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |