| | |
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: 763
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 |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card character class client code collision component crashcourse css csv database eclipse ee error fractal free ftp game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linux list loan machine map method methods migrate mobile netbeans objects oriented output panel phone physics problem program programming project projects radio recursion replaydirector reporting researchinmotion rotatetext scanner se server service set sms software sort sql string swing test textfield threads tree trolltech ubuntu utility windows





