Computer Science Canada Help With My PacMan Game |
Author: | helpmesodesperate [ Mon Feb 20, 2006 11:04 pm ] | ||
Post subject: | Help With My PacMan Game | ||
This is due in the morning, I've tried so many things to make the pill appear randomly and I just cant do anymore. I'm done. I want to go to sleep Ive been sitting here for 6 hours straight. Please help. The pill needs to appear randomly on the left side, then u eat it, then left side, then u eat it etc. and i wanted the backround to be black but whatever. Thanks. I will give you my soul for this.
|
Author: | Delos [ Mon Feb 20, 2006 11:34 pm ] | ||||
Post subject: | |||||
Please don't post titles in ALL CAPS again. It's very aggrevating. And learn to use your tags properly. I appreciate your trying to use them (more than what most people do), but really, they're not that difficult. First off:
is an infinite loop. It never exits, so your screen will always get filled with the blue circles once the initial condition is met. That being said, I'm not sure at all what the meaning of that condition is. From the layout of your screen, it's always going to be true. Which is not good. For this to work correctly, here's what you'll have to do: - initially set a position for the 'pill'. I'm guessing this is px and py. - draw your background, obstacles, character, and pill. - initiate movement checking (your getch() clauses) and get the character moving. - compare the character's position to px and py. When they coincide, the pill will be effectively 'eaten', and redraw it elsewhere (by resetting the values of px and py to different values). You will probably be using whatdotcolour() for this, since that's what you've been going with all this time. Personally, I'd prefer a mathematical approach, but something tells me you don't have the time to figure that one out. You probably won't have to manually clear the blue oval, since the character moving over it will do that for you - makes your life easier.
Why are you clearing the PacMan with the colour 'white' when your background is 'green'? Also, ever heard of View.Update()? It will make your animation smoother. This Tut will give you the basics on it. |
Author: | Isaac [ Mon Feb 20, 2006 11:47 pm ] | ||
Post subject: | |||
Here is something you can work with. What I'd suggest you do is just have an condition statement checking if the x,y of the pacman is on top of the dot. When it is, have make it generate a random x and y coordinate and draw it. Make sure that is in your loop, and it should go on forever and ever. Good luck.
|
Author: | chrispminis [ Sun Feb 26, 2006 11:55 pm ] |
Post subject: | |
What school are you attending? because I have this exact assignment. |