예제 #1
0
    def shoot(self):
        player = variables.player
        now = variables.time
        if (self.last_shot != None
                and now - self.last_shot < self.shot_interval):
            return
        self.last_shot = variables.time
        center = self.get_center()
        center = (center[1], center[0])
        shot = Shot(True)
        shot.sender = self
        shot.harm_player = True
        shot.x, shot.y = center[0], center[1]
        #Make shot follow player
        shot.speed = 250

        player_center = player.get_center()
        player_center = (player_center[1], player_center[0])
        diffx = (player_center[0] - center[0])
        diffy = (player_center[1] - center[1])

        shot.rotation = math.degrees(math.atan(diffx / diffy))
        if (diffy < 0):
            shot.rotation += 180
        shot.rotation += 180
        shot.move()

        variables.entities_to_add.add(shot)
예제 #2
0
 def fire(self):
     now = time.time()
     if (self.last_shot != None
             and now - self.last_shot < self.shot_interval):
         return
     self.last_shot = now
     shot = Shot()
     shot.sender = self
     #shot.sound.play()
     center = self.get_center()
     shot.y = center[0]
     shot.x = center[1]
     shot.rotation = self.rotation
     shot.move()
     variables.all_entities.add(shot)