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

Username:   Password: 
 RegisterRegister   
 How to make "Pacman" stop at a wall
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
falloutboysimpleplan




PostPosted: Wed Apr 02, 2008 8:32 pm   Post subject: How to make "Pacman" stop at a wall

I am pretty new at turing, and am making a Pacman game for school. I am having problems making him not go through the wall I made. I have been trying all day, have read many tutorials about collision and I still don't understand. Can someone please help me?
Sponsor
Sponsor
Sponsor
sponsor
falloutboysimpleplan




PostPosted: Wed Apr 02, 2008 8:46 pm   Post subject: RE:How to make "Pacman" stop at a wall

*sigh* i guess no one's gonna help me... well i give up... Sad
CodeMonkey2000




PostPosted: Wed Apr 02, 2008 9:32 pm   Post subject: RE:How to make "Pacman" stop at a wall

What method of collision are you trying to implement? And you need to wait longer than 15 minutes for a response Razz
Tony




PostPosted: Wed Apr 02, 2008 11:30 pm   Post subject: RE:How to make "Pacman" stop at a wall

Today at 8:32 pm : ...
Today at 8:46 pm : well i give up...

Collision detection comes in two major flavours

code:

if space ahead is a wall then
   don't move

and
code:

if space ahead is free then
   move


very similar, but they allow for somewhat different implementations. Depends if it's easier to store the location of the walls or the location of... not_walls. Either way, you'd probably need a matrix / grid / 2D array (all the same thing).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Jestar




PostPosted: Thu Apr 03, 2008 8:18 am   Post subject: RE:How to make "Pacman" stop at a wall

If your making a simple pacman you could try using View.WhatDotColor
Tony




PostPosted: Thu Apr 03, 2008 9:23 am   Post subject: RE:How to make "Pacman" stop at a wall

Ultimately whatdotcolour is the same as a 2D array. Though it has a per-pixel precision and it's contents are shared with graphics, so it's much more error prone.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
falloutboysimpleplan




PostPosted: Thu Apr 03, 2008 7:26 pm   Post subject: RE:How to make "Pacman" stop at a wall

Thanks for all your help guys, I really appreciate it. My problem is pretty much solved now except for I can't figure out how to make Pacman not go through the wall from the top and the bottom. If anyone has any ideas I'll post my code so far so they can have a look over. Any further help would be greatly appreciated.
syntax_error




PostPosted: Thu Apr 03, 2008 9:16 pm   Post subject: RE:How to make "Pacman" stop at a wall

set limits for the pacman

limit it's movement set the maxx and maxy values it can go up till.

and if you a bit more detailed help post your code so far and we can try to help you do it the best possible way.


as a side note, do wait more then 15 mins before giving up. Also dont always count on others to help you. THAT is an important lesson. very.
Sponsor
Sponsor
Sponsor
sponsor
SIXAXIS




PostPosted: Fri Apr 04, 2008 8:37 pm   Post subject: Re: How to make "Pacman" stop at a wall

If you're a beginner and don't know much about Turing, then I would say to use the View.WhatDotColor command. You just choose the pixels to check and it will hceck the colour. So here is an example:

% Draw pacman
drawfilloval (pacman_x, pacman_y, 10, yellow)
if whatdotcolor (pacman_x+11) = blue or whatdotcolor (pacman_x-11) = blue or whatdotcolor (pacman_y-11) = blue or whatdotcolor (pacman_y+11) = blue then
STOP PACMAN
end if

Something like that. The only problem is that nothing else in the game can be blue because it checks the pixel colour, not just what it's drawing or the line colour.
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  [ 9 Posts ]
Jump to:   


Style:  
Search: