Skip to content
Advertisement

Anyone know why pacman is not respecting the walls? When i press the keys to move pacman teleports between the walls

i’m trying to make a pacman game like pygame, now i just want him to walk through the maze without going beyond the walls of the maze. However I have faced some problems, when I press the keys to move the pacman, he ends up telephoning between the walls, although he does not exceed them it ends up bugging the coordinate system and starts to give a series of errors during the game commands . Does anyone know why this is happening and how to solve it?

JavaScript

SO every time i hold the keys to move for a few seconds the pacman goes over the blue walls of the project, does anyone know why and how to fix it?

Looks like he just teleports to the other sides and than bug the role coordinate system

Advertisement

Answer

There are 2 issues:

  1. The intention_column and intention_line depends on the current colume and line instead of the previous intention_column and intention_line. intention_column and intention_line are incremented even if there is a wall. colume and line however are only incremented if the movement is possible:
JavaScript
  1. Only update x_center and y_center if column or line are changed:
JavaScript

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement