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

Username:   Password: 
 RegisterRegister   
 Collision in Pac-Man
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Sean




PostPosted: Sat Jan 12, 2008 10:00 am   Post subject: Collision in Pac-Man

I have been making Pac-Man for turing for quite some time, before I started into procedures and that. At first, I drew my grid with a lot of lines, then shortened it to for loops.

But my question still rests on the collision I should be using. I've been told to use whatdotcolour since all my lines are the same colour and it would be the best to be used in mazes and such, which Pac-Man practically resides in.

My only problem is that I am having a slight problem understanding what to do. Whatdotcolour checks if the character hit a certain x, and y value and sees if it is a certain colour?
Sponsor
Sponsor
Sponsor
sponsor
Zampano




PostPosted: Sat Jan 12, 2008 11:27 am   Post subject: Re: Collision in Pac-Man

Yes, whatdotcolour will return the decimal number of the colour of the coordinate you provided it with.
Oh yeah, and what you di is have it an if, when it return true for the centre of Pacman plus his radius added or subtracted from his x or y, then either don't let input from the keyboard in, or subtract from Pacman x or y until the problem is solved.
Of course, since in Pacman you have multiple walls, I think (only think) that it would be best to only let Input in if whatdotcolour not= the value of the wall. Subtracting from his position is wrought with confusion.
I might be wrong though. It becomes far more complicated when Pacmans movement is more than 1 because he might go into a wall.
Gooie




PostPosted: Sat Jan 12, 2008 11:45 am   Post subject: Re: Collision in Pac-Man

If you're using a gird why not use that for collision, I could show you Monday if you want. Believe me, whatdotcolor for collision isn't fun.
Sean




PostPosted: Sat Jan 12, 2008 2:20 pm   Post subject: Re: Collision in Pac-Man

And your the one who suggested it Gooie.. I'll see you Monday then.
ericfourfour




PostPosted: Sat Jan 12, 2008 7:09 pm   Post subject: RE:Collision in Pac-Man

If the character is only moving one pixel per frame, whatdotcolour collision can be easily implemented.

The positions you should check are the top, bottom, left and right side of pacman. These depend on how you are representing pacman's position.

Circle, pacman's position is centre
Top: y + y radius
Bottom: y - y radius
Right: x + x radius
Left : x - x radius

Box, pacman's position is bottom left corner
Top: y + height
Bottom: y
Right: x + width
Left: x
Gooie




PostPosted: Sat Jan 12, 2008 11:07 pm   Post subject: Re: Collision in Pac-Man

Vilament @ January 12th, 2:20 pm wrote:
And your the one who suggested it Gooie.. I'll see you Monday then.


O hell, did I? I must have been just trying to get to my work that day, or It was pre-bomberman. Personally I have not gotten whatdotcolor to work properly.
Sean




PostPosted: Sun Jan 13, 2008 9:48 am   Post subject: Re: Collision in Pac-Man

Gooie @ Sat Jan 12, 2008 11:07 pm wrote:
Vilament @ January 12th, 2:20 pm wrote:
And your the one who suggested it Gooie.. I'll see you Monday then.


O hell, did I? I must have been just trying to get to my work that day, or It was pre-bomberman. Personally I have not gotten whatdotcolor to work properly.


You did, but you weren't doing school work, was Bomberman.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: