This site requires JavaScript, please enable it in your browser!
Greenfoot back
JMGames
JMGames wrote ...

2013/10/26

Making walls

JMGames JMGames

2013/10/26

#
How can i programm it that my 'Hero' doesn't walk on walls?
askgriff askgriff

2013/10/26

#
Hi JM -- the way I worked through it was I created a block (Class) called "Wall". Then I had my Player (Class) check for isTouching(). So for example, I would say "if the left arrow is pressed move -5" and then I would check to see if it was touching a wall -- and if it was, I would say move +5 to take away the move. You can look in my recent Zombie scenario. http://www.greenfoot.org/scenarios/9541 I think I'm using the "isTouching" method in this one. If not, the current version does and it will be updated to that shortly.
JMGames JMGames

2013/10/26

#
thanks :)
You need to login to post a reply.