Computer Science Canada Pacman coins/dots |
Author: | Montyman77 [ Mon Jun 08, 2009 8:54 pm ] | ||
Post subject: | Pacman coins/dots | ||
What is it you are trying to achieve? <Replace all the <> with your answers/code and remove the <>> What is the problem you are having? <Answer Here> Describe what you have tried to solve this problem <Answer Here> Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using <Answer Here> |
Author: | Montyman77 [ Mon Jun 08, 2009 9:13 pm ] | ||
Post subject: | Re: Pacman coins/dots | ||
Somehow in the process of attatching files my text got pwned so here it is What is it you are trying to achieve? Im making a pacman game and i can't get them to disappear What is the problem you are having? my dots are being drawn in a for loop and my bckground is redrawn every time my main loop runs so any way i cover up the coins they come back on top Describe what you have tried to solve this problem i have no ideas Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) here is the loop that draws the coins the rest is attatched
Please specify what version of Turing you are using 4.1.1 |
Author: | Montyman77 [ Mon Jun 08, 2009 9:15 pm ] |
Post subject: | Re: Pacman coins/dots |
can a mod remove the text at the top and keep the files attatched? thanks P.S. i just realized that i could've edited it |
Author: | BigBear [ Tue Jun 09, 2009 1:36 pm ] |
Post subject: | RE:Pacman coins/dots |
It is easier to attach a zip with all the files in a single download |
Author: | TheGuardian001 [ Tue Jun 09, 2009 3:17 pm ] |
Post subject: | Re: Pacman coins/dots |
Well, you could do this several ways, the easiest would be to have an array of boolean (one value for each dot/coin) that stores whether or not that dot has been eaten. If it hasn't, draw the dot, if it has, move on to the next dot. The only problem is that you haven't actually made the coins proper objects, they're just images that are drawn every time regardless. You should store the x, y, and eaten values in arrays, then draw based off of those values. This allows you to change their properties, like whether they should be drawn or not. |
Author: | Montyman77 [ Tue Jun 09, 2009 8:05 pm ] |
Post subject: | RE:Pacman coins/dots |
ok that makes sense but how do i draw proper objects? |
Author: | TheGuardian001 [ Tue Jun 09, 2009 8:40 pm ] | ||
Post subject: | Re: Pacman coins/dots | ||
TheGuardian001 wrote: You should store the x, y, and eaten values in arrays, then draw based off of those values. This allows you to change their properties, like whether they should be drawn or not. If you're actually holding your values somewhere, you are free to change them at will. So if mario walks over a dot, you simply set the "eaten" value for that dot to "true". then, when you're drawing, you do something like this
Using arrays has the added bonus of making collision detection really really easy. you just use a for loop to check the X and Y values of each dot against Mario's position. |
Author: | Montyman77 [ Wed Jun 10, 2009 8:20 pm ] |
Post subject: | RE:Pacman coins/dots |
thank you very much! it took a bit of work but I figured it out |