Пример #1
0
    def update(self):
        """moves the bullet in the direction of the target"""

        selfx, selfy = self.rect.center
        targx, targy = self.target.rect.center
        direction = round_to_45(get_direction(self.rect.center, self.target.rect.center))

        self.move(direction)
Пример #2
0
    def update(self):
        """moves the bullet in the direction of the target"""

        selfx, selfy = self.rect.center
        targx, targy = self.target.rect.center
        direction = round_to_45(
            get_direction(self.rect.center, self.target.rect.center))

        self.move(direction)
 def move(self, direction):
     """moves the sprite in the given direction
     
     direction should be a tuple representing a unit vector
     """
     
     if direction in DIRECTIONS.keys():
         self.current_dir = direction
     else:
         self.current_dir = round_to_45(direction)
     
     ASprite.move(self, direction)