def move_pacman(self, position, direction, image): """Move pacman to given position; this is called by animate_pacman.""" screen_position = self.to_screen(position) endpoints = self.get_endpoints(direction, position) r = PACMAN_SCALE * self.grid_size gu.move_circle(image[0], screen_position, r, endpoints) gu.refresh()
def move_eyes(self, pos, dir, eyes): """Move ghost's eyes.""" (screen_x, screen_y) = (self.to_screen(pos)) dx = 0 dy = 0 if dir == 'North': dy = -0.2 if dir == 'South': dy = 0.2 if dir == 'East': dx = 0.2 if dir == 'West': dx = -0.2 gu.move_circle( eyes[0], (screen_x + self.grid_size * GHOST_SIZE * (-0.3 + dx / 1.5), screen_y - self.grid_size * GHOST_SIZE * (0.3 - dy / 1.5)), self.grid_size * GHOST_SIZE * 0.2) gu.move_circle( eyes[1], (screen_x + self.grid_size * GHOST_SIZE * (0.3 + dx / 1.5), screen_y - self.grid_size * GHOST_SIZE * (0.3 - dy / 1.5)), self.grid_size * GHOST_SIZE * 0.2) gu.move_circle(eyes[2], (screen_x + self.grid_size * GHOST_SIZE * (-0.3 + dx), screen_y - self.grid_size * GHOST_SIZE * (0.3 - dy)), self.grid_size * GHOST_SIZE * 0.08) gu.move_circle(eyes[3], (screen_x + self.grid_size * GHOST_SIZE * (0.3 + dx), screen_y - self.grid_size * GHOST_SIZE * (0.3 - dy)), self.grid_size * GHOST_SIZE * 0.08)