中途岛海战大敌机类设计程序

中途岛海战大敌机类设计程序

这是本人开发的飞机大战中途岛海战里的rover漫游的大敌机模块。它有上升,攻击,下沉,IDLE状态。

下面是部分代码预览:

"""
   中途岛海战的敌机,送子弹与生命值的,
   这架敌机经常会在云下面,这时候,无法射击它。
   当它在云上面时,才能够被击中。
"""

__author__= '李兴球'
__date__ = '2019/9/12'

import time
import pygame
from pygame.locals import *
from random import *

class Enemy_rover(pygame.sprite.Sprite):
    """
       随机移动的敌机,有三种状态,当往上升的时候,大小越来越大。
       当在云上的时候这时可以被击中,被击时会显示另一个造型,
       当往下移的时候,越来越小。
    """
    def __init__(self,images,hurt_image,explosion_images,screen):
        """
          images:从小到大的造型列表,
          hurt_image:被击中时的造型,
          explosion_images:爆炸时的造型列表,
          screen:所在屏幕
        """
        pygame.sprite.Sprite.__init__(self)
        # 爆炸造型列表
        self.explosion_images = explosion_images
        self.explosion_rects = [im.get_rect() for im in explosion_images]
        self.explosion_amounts = len(explosion_images)
        # 被攻击时的造型 
        self.hurt_image = hurt_image
        self.hurt_rect = hurt_image.get_rect()
          
    def set_costume(self):
        """设置造型"""

    def bounce_on_edge(self):
        """碰到边缘就反弹"""
    
    def update_status(self):
        """根据状态来更新造型等"""
            
    def update(self):
        """更新状态,造型与位置"""

                
if __name__ == "__main__":

    width,height = 960,720
    screen = pygame.display.set_mode((width,height))
    pygame.display.set_caption("中途岛海战大敌机测试程序 by lixginqiu")
    
    .........................
    
    clock = pygame.time.Clock()
    running = True
    while running:
        for event in pygame.event.get():
            if event.type == QUIT:running = False
            if event.type == KEYDOWN: rover.attacking = True
            if event.type == KEYUP:rover.attacking=False

        rover_group.update()

        screen.fill((0,0,0))
        rover_group.draw(screen)

        pygame.display.update()
    pygame.quit()        

 如需要查看完整源代码,请

成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

李兴球

李兴球的博客是Python创意编程原创博客

评论已关闭。