#-*- coding: UTF-8 -*- import pygame from pygame.locals import * import time import random from baseImage import BaseImage class Bullet(BaseImage): """基础子弹类,可视为工厂""" def __init__(self,x,y,bgScreen,type): #生成子弹位置 self.x = x self.y = y #根据类别选择子弹图片 if type == "Hero": self.imageName = "./images/bullet-3.gif" elif type == "Enemy": self.imageName = "./images/bullet-1.gif" super(Bullet,self).__init__(bgScreen) def move(self,direction,speed=1): if direction == "up": self.y -= speed elif direction == "down": self.y += speed