Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-01-2007, 05:28 PM
Member
 
Join Date: Jul 2007
Posts: 40
cachi is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 08:48 AM
Member
 
Join Date: Jul 2007
Posts: 40
toby is on a distinguished road
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).
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HashMap: Obtaining all values in a collision? markus-sukram New To Java 2 03-29-2008 11:25 PM
Collision Detection (Game) mscwd Sun Java Wireless Toolkit 0 01-28-2008 09:34 PM
Listener for SWT event Java Tip Java Tips 0 01-08-2008 10:04 AM
Two Problems Rotating and collision detection help jaferris Java Applets 2 01-08-2008 12:19 AM
Implementing "Game Over" in Minesweeper game based on Gridworld framework. JFlash New To Java 0 11-16-2007 12:02 AM


All times are GMT +3. The time now is 07:42 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org