![]() |
| ||
| java 2d games problem (collision, well prevention) I am starting to make some java games and I think i have sorted out the collision side of things ( i have made a space invaders game) so i know how to shoot and kill enemies. I am now wanting to stop players/monsters going through walls etc? p.s. what is the best way to do walls? (just paint() them) thanks for you help |
| ||
| Re: java 2d games problem (collision, well prevention) If you just have simple, axis-aligned walls, then just compare the distance between the enemy and wall with the size of the enemy. If the distance becomes less, then it has hit the wall. After that, just reverse the direction of the enemy. That's the most simple of collision methods. Others involve swept collisions, which work regardless of an object's speed. |
| ||
| Re: java 2d games problem (collision, well prevention) problem solved just stored the values like GTC[0]=x; GTC[1]=y; before the collsion and where it collides if (a instanceof Monster ) { x = GTC[0]; y = GTC[1]; } |
| All times are GMT -4. The time now is 4:03 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC