def __init__(self,x,y,orientation, img_name = None): """ Creates a Bullet. arguments: x - the starting x position y - the starting y position orientation - the starting orientation for rotating the sprite image img_name - optional name for an image file to use for the sprite's master image. By default, the sprite will look for an image called 'bullet.png'. """ img = python_nameconfig.default_bullet if img_name != None: img = img_name BaseSprite.__init__(self, img) self.launch_sound = pygame.mixer.Sound(python_nameconfig.guy_shoot_sound) self.launch_sound.play() self.explosionSound = pygame.mixer.Sound(python_nameconfig.guy_bullet_explode) self.orientation = orientation self.x = x self.y = y self._accelerating = True self.acceleration_divisor = .75 self.max_velocity = 100 self.max_ticks = 10 self.ticks = 0 self.exploding = False self.explodestage = 0 self._update_image()
def __init__(self, target, img): """ Create a HomingMissle. Useful as an enemy or as a weapon for the player. arguments: target - A sprite that the homing missle atempts to track down and shoot img - A path to an image to use for the missle """ BaseSprite.__init__(self, img) self.init_position() self.target = target self._rotating_left = False self._rotating_right = False #the missle starts out moving self._accelerating = True #the missle starts out not knowing if it is #pointed at the target self.targetted = False self.explode_stage = 0 self.exploding = False self.explosion_sound = pygame.mixer.Sound(python_nameconfig.enemy_explode_sound) self.points = 1
def __init__(self): """Creates an Enemy """ BaseSprite.__init__(self, python_nameconfig.enemy_image) self.points = 1 self.explosion_sound = pygame.mixer.Sound(python_nameconfig.enemy_explode_sound) self.explode_stage = 0 self.exploding = False
def __init__(self, bullets_group): """ Creates a Guy arguments: bullets_group - A pygame.SpriteGroup managed by the games collision detection system. """ BaseSprite.__init__(self, python_nameconfig.guy_img) self.bullets = bullets_group self.hum = pygame.mixer.Sound(python_nameconfig.guy_eng) self.explosionSound = pygame.mixer.Sound(python_nameconfig.guy_explode) self.exploding = False self.explodestage = 0 self.visible = True self.max_bullets = 4