中途岛海战Boss发射一拔子弹类的设计

"""
   中途岛海战大boss发射的子弹类设计,
   游戏中最后的boss会不定时的发射一序列大颗粒子弹,这些子弹都会向下散射。
   
"""
__author__ = "李兴球"
__date__ = "2019/9/13"

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

def spawn_boss_bullet():
    """产生一些子弹"""
    global bbcounter,bbg
    bbcounter += + 1
    bbcounter %= 1000
    if bbcounter % randint(5,10) == 0 and bbcounter < 300:
        bbi = boss_bullet_image
        pos = width//2,height//2
        b = Boss_Bullet(bbi,pos,screen)
        bbg.add(b)


def main():
    """主要函数"""
    width,height = 960,720
    screen = pygame.display.set_mode((width,height))
    pygame.display.set_caption("中途岛海战Boss发射一拔子弹测试 by lixingqiu")
    boss_bullet_image = pygame.image.load('boss_images/boss_bullet.png').convert_alpha()
   
    bbg = pygame.sprite.Group()
    clock = pygame.time.Clock()
    bbcounter = 0
    running = True
    while running:
        for event in pygame.event.get():
            if event.type == QUIT:running = False
        spawn_boss_bullet()
        bbg.update()
        screen.fill((0,31,43))
        bbg.draw(screen)
        pygame.display.update()
        clock.tick(60)
        
    pygame.quit()
    
class Boss_Bullet(pygame.sprite.Sprite):
    """boss发射的子弹"""
    

You must log in to read the rest of this article. Please log in or register as a user.