Computer Science Canada Pacman help |
Author: | sarah [ Thu Mar 22, 2007 7:45 pm ] | ||
Post subject: | Pacman help | ||
I was wondering if anyone could help me figure out how to make my pacman game run properly. I can't get the pacman to stop when he hits a wall, or get him to eat the dots. I've looked through quite a few tutorials and nothing seems to be helping. Any advice at all would really be appriciated. Here is the code:
|
Author: | samuelkyl [ Thu Mar 22, 2007 8:39 pm ] |
Post subject: | Re: Pacman help |
I just started turing, and need to get familiar with it to help your wall question, but for the pill, I could see the problem. You put dx and dy in the Math.Distance function, change those to x and y, and also, put an exit statement after the "pacman ate the pill". Then move that whole block out of that if statement and right above the end of the loop statement. Good job with the drawing of the picture, tho. Even though it could be improved, it's pretty creative. Also check your co-ord +- for your whatdotcolours, some of them are erroneous.. ![]() |
Author: | sarah [ Thu Mar 22, 2007 9:09 pm ] |
Post subject: | Re: Pacman help |
thank you so much. The math.distance works great now ![]() |
Author: | richcash [ Fri Mar 23, 2007 11:16 pm ] | ||
Post subject: | Re: Pacman help | ||
There is a different approach that works great for a game like pacman that is more simplistic. You can use it if you want to make life easier, or stay with your own. Mentally split the screen up into squares (for example, 10 X 10). In each square, there will be something different. Either it will be a dot, pacman (or a piece of pacman), a piece of a wall, an enemy, or nothing at all. Basically, we can just have a 2 dimensional array represent each of these squares and assign the array elements with 0 for nothing, 1 for pacman, 2 for a dot, 3 for a piece of wall, 4 for an enemy, etc. This way, collision detection becomes so easy, because you can just check if the square pacman is about to move to has a dot, enemy, or wall and act accordingly. Here is a quick example of what I mean.
|
Author: | tenniscrazy [ Thu Apr 19, 2007 10:58 am ] |
Post subject: | Re: Pacman help |
I might use that idea for my pacman game im making thanks |