...

java: collision listener for a game

warhammerdude20
08-06-2004, 03:48 AM
hey,

i have been making very simple games for java for awhile now but i have come across yet another problem.

all the games i made just had about 3 or 4 objects that needed collision detection... so i just put it in the while loop in the run() method of the applet.

well that worked out fine but as i am getting more in to a more advanced game it is starting to get messy(and slower). i intend to have alot of collisions in this game. then i look at a game like mario 64 and think that they couldnt have checked for collisions in every step. so i figured there is some way to write a listener(like a mouse listener or a key listener) that could wait for some variables to equal something then trigger the action.

i have searched far and wide(on the web..) for how to do this but i have found nothing.

is the only way to detect collisions in an infinite loop or is there another way?

thx :cool: :thumbsup:

nolachrymose
08-06-2004, 04:02 PM
Whenever an object moves in the game that can collide with another, you should check for a collision. So whenever event invokes movement on such an object, you should check for a collision (for instance, if the player is moved by keys, you check the if the player has collided with anything).

Hope that helps!

Happy coding! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum