advsite.blogg.se

Pacman chasing ghosts
Pacman chasing ghosts













pacman chasing ghosts

MazeRect = MazeSurface.get_rect(topleft = (Player. MazeSurface = pygame.Surface((Player.MAZE_WIDTH, Player.MAZE_HEIGHT)) you may want to focus on collecting Pac-Dots instead of chasing ghosts. If PinkGhostRect.y = self.TimeBetweenBites:ĬurrentSurface = (CurrentSurface, 180)ĬurrentSurface = (CurrentSurface, 90)ĬurrentSurface = (CurrentSurface, 270)īackgroundSurface = (BackgroundSurface,īackgroundRect = BackgroundSurface.get_rect() When possible, move your ghost not just where PAC-MAN is, but where you think. Self.GhostWallDetection(0, -1, PinkGhostRect) Self.GhostWallDetection(-1, 0, PinkGhostRect) MazeSurface.blit(BlueGhostSurface, BlueGhostRect) MazeSurface.blit(RedGhostSurface, RedGhostRect) MazeSurface.blit(YellowGhostSurface, YellowGhostRect) MazeSurface.blit(PinkGhostSurface, PinkGhostRect) Return str(self.SCORE), str(self.HIGH_SCORE) Self.PacManWallDetection(0, 1, CurrentRect)ĭef PacManWallDetection(self, x, y, CurrentRect):ĭef GhostWallDetection(self, x, y, PinkGhostRect):ĬOLLIDE = lliderect(WALL) Self.PacManWallDetection(0, -1, CurrentRect) Self.PacManWallDetection(1, 0, CurrentRect)

pacman chasing ghosts

Doing this will make the ghost follow Pacman wherever he goes like a lost puppy. Self.PacManWallDetection(-1, 0, CurrentRect) CHASE: This, like the scatter mode, is different for all of the ghosts. If key and not key \Įlif key and not key \ Self.DECISION_NODES.append([(self.BLOCK_WIDTH * COLUMN), Hope this is in the right category, if not, sorry in advance I coding a PacMan game clone, currently the ghosts chase pacman character by moving towards with. Self.MAZE_HEIGHT = self.BLOCK_HEIGHT * len(self.MATRIX)įor COLUMN in range(len(self.MATRIX)): Self.MAZE_WIDTH = self.BLOCK_WIDTH * len(self.MATRIX) Self.MAZE_Y = self.BLOCK_HEIGHT * (len(self.MATRIX) Self.MAZE_X = self.BLOCK_WIDTH * (len(self.MATRIX) # 5 - Decision Nodes & will be added for intersections in maze RedGhostRect = RedGhostSurface.get_rect()īlueGhostSurface = (("BlueGhost.png")īlueGhostRect = BlueGhostSurface.get_rect() YellowGhostRect = YellowGhostSurface.get_rect() PinkGhostRect = PinkGhostSurface.get_rect() PacManRect = PacManStartSurface.get_rect(topleft =īackgroundSurface = ("Background.png").convert() PacManStartRect = PacManStartSurface.get_rect(topleft = # Sets the WIDTH and HEIGHT of the window # Frames per second, how fast the game runs # Sets the size of the screen via (WIDTH, HEIGHT)

PACMAN CHASING GHOSTS HOW TO

So I've been trying to recreate the PacMan Game, I have been stuck on how to approach the idea of the Ghosts moving around the maze, I've heard of A* and Dijkstra's Algorithms, but is there a simpler way to implement ghosts moving around the maze? Aside from figuring out the different modes they can go into, Frightened, Chase, and Scatter, I just want to be able to understand whats the best way to get them to move randomly in the maze with the wall detection function in place.















Pacman chasing ghosts