|
Listener collision on game
Hi, 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 a lot of collisions in this game. then i look at a game like Mario 64 and think that they couldn't 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?
Thanks.
|