PDA

View Full Version : how to make a barrier


davise
11-03-2009, 09:45 AM
I am trying to make a replication of the Pac-Man game, and I was wondering if there is a way to make a barrier in the course that your "pac-man" can not go through...

i.e.-the arrow keys move the "pac-man" and you have to collect all the "dots" but i need it to where the "pac-man" can not go through the wall so that they cant be caught by the "bad pac-man"....

If someone could explain to me how to do this or possibly make a world for example code that would be great.


Thanks,
Evan

dubastot
11-03-2009, 10:00 PM
Well you could make a series of rectangles to form a maze. Then you create a group named walls with all those. Then write your code like this:

loop infinity times
for all together
if pacman is within 1 meter of walls
pacman move backward 1 meter

davise
11-05-2009, 09:10 AM
Thanks I will try that after I get the maze set up(which will take a while)but i'll tell you how it all worked out, and I might post the world on here after we finish it(but the might be quite a while too)