예제 #1
0
파일: ghost.py 프로젝트: Kranek/PacMan
    def __init__(self, x, y, anim, rect_martix, container, evenent_handler):
        super().__init__(x, y, rect_martix, container, evenent_handler)
        self.standard_anim = anim
        self.current_anim = anim
        self.corner_changer = 0
        self.house_time = 1
        self.scatter_time = 1000
        self.corner_points = []
        self.is_dot = True
        self.is_scared = False
        self.change_direction_counter = 1
        self.stupidity = 3
        self.react_cases = {POWER_UP: self.run_away, BACK_TO_CHASE: self.back_to_chase}
        self.move_functions = {CHASE: self.chase_move, SCATTER: self.scatter_move,
                               SCARED: self.scared_move, HOUSE: self.house_move,
                                   FROZEN: self.stand_still, HOUSE_RETURN: self.house_return_move}
        self.move_hero_function = self.house_move
        self.new_directions = get_next_directions((round(self.y / 20), round(self.x / 20)),
                                                    (round(self.container.pac_man.y / 20), round(self.container.pac_man.x / 20)))
        self.last_predicted_rect = []
        self.new_directions_painted = False
        for key, animation in self.standard_anim.items():
            animation.play()

        self.container.add_object(self)
예제 #2
0
파일: ghost.py 프로젝트: Kranek/PacMan
 def get_directions_to_closest_pacman(self):
     if self.container.enemy_pac_man is None:
         self.new_directions = get_next_directions(self.map_point, self.container.pac_man.map_point)
     else:
         if self.container.pac_man.active:
             directions_to_player = get_next_directions(self.map_point, self.container.pac_man.map_point)
         else:
             directions_to_player = [self.get_proper_random_direction()]
         if self.container.enemy_pac_man.active:
             directions_to_enemy = get_next_directions(self.map_point, self.container.enemy_pac_man.map_point)
         else:
             directions_to_enemy = [self.get_proper_random_direction()]
         if len(directions_to_enemy) == 0 and len(directions_to_player) == 0:
             return [self.get_proper_random_direction()]
         self.new_directions = directions_to_player if len(directions_to_player) <= len(directions_to_enemy) else directions_to_enemy
     return self.new_directions
예제 #3
0
파일: clyde.py 프로젝트: Kranek/PacMan
 def get_directions(self):
     directions_to_pacman = self.get_directions_to_closest_pacman()
     directions_to_left_corner = get_next_directions(self.map_point, (27, 2))
     if len(directions_to_pacman) <= 8:
         self.stupidity = len(directions_to_left_corner)
         return directions_to_left_corner
     else:
         self.stupidity = 6
         return directions_to_pacman
예제 #4
0
파일: ghost.py 프로젝트: Kranek/PacMan
 def house_return_move(self):
     if self.in_place_to_change_direction():
         self.map_point = self.rect_matrix.get_map_point(self.area_rect)
         self.is_dot = self.is_dot_at_field()
         self.new_directions = get_next_directions(self.map_point, (13, 14))
         if len(self.new_directions) == 1:
             self.is_scared = False
             self.reload_movements()
             self.current_anim = self.standard_anim
             self.change_move_hero_function(CHASE)
         else:
             self.direction = self.new_directions[0]
예제 #5
0
파일: ghost.py 프로젝트: Kranek/PacMan
    def scatter_move(self):
        if self.in_place_to_change_direction():
            self.map_point = self.rect_matrix.get_map_point(self.area_rect)
            self.is_dot = self.is_dot_at_field()
            self.new_directions = get_next_directions(self.map_point, self.corner_points[self.corner_changer])
            if len(self.new_directions) < 2:
                self.corner_changer += 1
                if self.corner_changer == len(self.corner_points):
                    self.corner_changer = 0
        self.direction = self.new_directions[0]

        # TODO change_move_hero_function should not be called from any ghost class!!!
        self.scatter_time -= 1
        if self.scatter_time == 0:
            self.change_move_hero_function(CHASE)
예제 #6
0
파일: ghost.py 프로젝트: Kranek/PacMan
 def scared_move(self):
     if self.in_place_to_change_direction():
         self.map_point = self.rect_matrix.get_map_point(self.area_rect)
         self.is_dot = self.is_dot_at_field()
         self.direction = get_next_directions(self.map_point, self.container.pac_man.predicted_pac_man_point(20))[0]
예제 #7
0
파일: inky.py 프로젝트: Kranek/PacMan
 def chase_move(self):  # sprawa z argumentami do przemyslenia
     self.new_directions = get_next_directions(self.map_point, self.get_proper_target())