Results 1 to 2 of 2
  1. #1
    cachi is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default 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.

  2. #2
    toby is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default

    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).

Similar Threads

  1. Replies: 2
    Last Post: 08-05-2010, 04:49 AM
  2. HashMap: Obtaining all values in a collision?
    By markus-sukram in forum New To Java
    Replies: 2
    Last Post: 03-29-2008, 10:25 PM
  3. Collision Detection (Game)
    By mscwd in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 01-28-2008, 08:34 PM
  4. Listener for SWT event
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 09:04 AM
  5. Two Problems Rotating and collision detection help
    By jaferris in forum Java Applets
    Replies: 2
    Last Post: 01-07-2008, 11:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •