We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I would like place a user-controlled player inside a game made from AI_for_2D_games library. But having problems with wall and bullet collision. Did I need to load an extra collision map for constrain player to the wall like this http://processing.org/discourse/beta/num_1272507983.html or is there other ways?
Answers
PLAYER WALL CONSTRAINT
If you simply want to prevent the player passing through the wall, then you can create an object of type Vehicle (or from a class that extends Vehicle) and use the Wall Avoidance behaviour. Then use these methods to tweak the player / wall interaction.
My website has some guides on these Wall Avoidance and Tweaking the Steering Behaviour
BULLET WALL COLLISION DETECTION
I am assuming that In this case we simply need the bullet to disappear when it hits a wall. In this case the bullet must be created from the MovingEntity class (or any class that extends MovingEntity) and add a method to detect a collision with a wall.
There are several ways of coding this, all of which are difficult to explain in words so I have created a simple applet to demonstrate the most flexible approach. The code is below and you can see it in action HERE.
Woo. That really works. Thanks. Never thought define player unit as Vehicle.