Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Pacman coins/dots
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Montyman77




PostPosted: 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>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>



red pipe2.bmp
 Description:
 Filesize:  6.71 KB
 Viewed:  3250 Time(s)

red pipe2.bmp



red pipe.bmp
 Description:
 Filesize:  6.15 KB
 Viewed:  3250 Time(s)

red pipe.bmp



mario.bmp
 Description:
 Filesize:  594 Bytes
 Viewed:  3250 Time(s)

mario.bmp



background-new.jpg
 Description:
 Filesize:  148.66 KB
 Viewed:  111 Time(s)

background-new.jpg



game.t
 Description:
images also attatched

Download
 Filename:  game.t
 Filesize:  9.22 KB
 Downloaded:  128 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Montyman77




PostPosted: 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

Turing:

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




PostPosted: 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
BigBear




PostPosted: 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
TheGuardian001




PostPosted: 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.
Montyman77




PostPosted: Tue Jun 09, 2009 8:05 pm   Post subject: RE:Pacman coins/dots

ok that makes sense but how do i draw proper objects?
TheGuardian001




PostPosted: 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

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


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




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: