Archived

This topic is now archived and is closed to further replies.

Sand_Hawk

Pacman

Recommended Posts

Hi guys, I have a question about a pacman clone I''m trying to make. I don''t haven''t coded yet because I always try to figure things out before starting coding. I always thing it out inside my brain and when I have completed all the thinking(I think when I''m done thinking I mean) I write down the entire idea and stuff. After that I make a good planning and start coding. On this moment I''m still in the think phase. It might sound a bit weird but I works perfectly for me because most hard parts are already done in my brain and a sitting on paper when I code. But here is my question: How do I make the pacman move between two walls? Look at the example: * = wall X = pacman *** **** X This one is easy. Just go up. But what if my Pacman is just one pixel more to the left? Then it means that I don''t am able to go up with my pacman. Any help is welcome. This is my second game I''m trying to create. Thank you, Sand Hawk

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just have him roll along the wall. A lot of games do this. If you push up and you can''t go that way, you go left along the wall instead.

If you want to be fancy, figure out the nearest opening and move him towards it.

Share this post


Link to post
Share on other sites
The way I did it in my pacman clone is, I used a second "direction" variable. What I do is I keep the current direction in one variable, and the "next" direction in another. So say for example you turn to the left around a corner, and then the next direction is to the left again, pacman will check a wall that it can go through on the left side, even if you are not pressing the key anymore. This is what the original pacman looked like, and it makes it easier to play, otherwise you would be "sticking" to the walls way too often and that would ruin the fun of the game. Also make the maze cooridors to be the same size as your pacman and the enemies. This will help as well.

If you need more help, let me know.

Later,
Viktor

Share this post


Link to post
Share on other sites