| | |
java 2d games problem (collision, well prevention)
![]() |
•
•
Join Date: Oct 2004
Posts: 44
Reputation:
Solved Threads: 0
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
p.s. what is the best way to do walls? (just paint() them)
thanks for you help
•
•
Join Date: Mar 2004
Posts: 762
Reputation:
Solved Threads: 38
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.
![]() |
Similar Threads
- Java Problems (Windows 95 / 98 / Me)
- Java GUI problem... contents of JFrame is invisible... (Java)
- basic java GUI problem (Java)
- Java Problem (Windows NT / 2000 / XP)
- java chat problem (Windows 95 / 98 / Me)
Other Threads in the Java Forum
| Thread Tools | Search this Thread |
-xlint actionlistener android api applet application array automation bi binary blackberry block bluetooth character class client code compile compiler component consumer database desktop developmenthelp eclipse error fractal freeze ftp functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide image int j2me j2seprojects java javac javaee javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux mac main map method mobile myregfun netbeans nonstatic notdisplaying number online pearl printf problem program project qt researchinmotion rotatetext rsa scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor





