
-----------------------------------
Montyman77
Mon Jun 08, 2009 8:54 pm

Pacman coins/dots
-----------------------------------
What is it you are trying to achieve?



What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using


-----------------------------------
Montyman77
Mon Jun 08, 2009 9:13 pm

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


proc coins
    var coinx : real := 122
    var coiny : real := 45
    var roundx, roundy : int
    for f : 1 .. 20
        for i : 1 .. 17
            roundx := round (coinx)
            roundy := round (coiny)
            if whatdotcolor (roundx, roundy) = 192 then
                drawfilloval (roundx, roundy, 3, 4, 14)
            end if
            coinx += 24.4
        end for
        coiny += 17.4
        coinx := 122
    end for
    
end coins



Please specify what version of Turing you are using
4.1.1

-----------------------------------
Montyman77
Mon Jun 08, 2009 9:15 pm

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

-----------------------------------
BigBear
Tue Jun 09, 2009 1:36 pm

RE:Pacman coins/dots
-----------------------------------
It is easier to attach a zip with all the files in a single download

-----------------------------------
TheGuardian001
Tue Jun 09, 2009 3:17 pm

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.

-----------------------------------
Montyman77
Tue Jun 09, 2009 8:05 pm

RE:Pacman coins/dots
-----------------------------------
ok that makes sense but how do i draw proper objects?

-----------------------------------
TheGuardian001
Tue Jun 09, 2009 8:40 pm

Re: Pacman coins/dots
-----------------------------------

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

[code]
for i : 1 .. MaxDot
       check DotEaten(i) %array to hold values of if they're eaten, True or False
            False
                Draw Dot(DotX(i),DotY(i)) %Draw at that dot ( dot #i )'s x and y coordinates, also stored in arrays.
            True
                Ignore
       end
end
[/code]

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.

-----------------------------------
Montyman77
Wed Jun 10, 2009 8:20 pm

RE:Pacman coins/dots
-----------------------------------
thank you very much!
it took a bit of work but I figured it out
