hey,
I am trying to make some kind of pacman game, but I have no idea how to stop my pacman from going trough the walls.
I am using pictureboxes for pacman and for the walls. Is there some kind of code for this?
Printable View
hey,
I am trying to make some kind of pacman game, but I have no idea how to stop my pacman from going trough the walls.
I am using pictureboxes for pacman and for the walls. Is there some kind of code for this?
Shouldn't be a problem. The figures move in a straight line either vertical or horizontal. So if you have a tunnel let's say with wall on both sides then your figures need to move up/down and left/right without touching the walls. If you just make the center line of a figure move on top of the center line of the tunnel then they should never "go through the walls"
Take a look at my A* Pathfinding in my signature. Not only will this help with wall collision, but also give you a nice chase algorithm for your ghosts. It also has not just pathfinding but pathfollowing as well.
[EDIT] Also don't use a bunch of pictureboxes to setup the worlds. Its better to actually work with graphical APIs or even DirectX.