Game Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesGame Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 29th, 2006, 04:13 PM
william_nagels william_nagels is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Location: belgium
Posts: 116 william_nagels User rank is Private First Class (20 - 50 Reputation Level)william_nagels User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 7 h 2 m 45 sec
Reputation Power: 7
Send a message via MSN to william_nagels
Java applets games

can someone tell me how to register 2 objects who hit each other?
I mean when they hit each other.

what i'm meaning is that.
you got a rectangele
g.drawRect(...,...,...,...);
and an oval
g.drawOval(...,...,...,...,);

the oval moves up.
and hit's the rectangel on any spot
then it goes back.
if the oval misses the rectangle
it passes the border of the applet and is gone

sry for my bad English but I'm a foreigner

Reply With Quote
  #2  
Old August 30th, 2006, 02:26 AM
Hugh of Borg's Avatar
Hugh of Borg Hugh of Borg is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Location: Switzerland
Posts: 1,152 Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 19 h 1 m 52 sec
Reputation Power: 1900
You're looking for collision detection algorithms.

An easy way would be to think of the oval as a rectangle too and if one of the 2 object's corners are inside the other object you have a collision.
__________________
- Hugh of Borg

The first thing young borg are taught: Keep away from Microsoft software!

Reply With Quote
  #3  
Old August 30th, 2006, 01:33 PM
william_nagels william_nagels is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Location: belgium
Posts: 116 william_nagels User rank is Private First Class (20 - 50 Reputation Level)william_nagels User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 7 h 2 m 45 sec
Reputation Power: 7
Send a message via MSN to william_nagels
and how would i do that :s

Quote:
Originally Posted by Hugh of Borg
An easy way would be to think of the oval as a rectangle too and if one of the 2 object's corners are inside the other object you have a collision.


tnx for reply but how can i do that?

ypos_rect - ypos_circ && xpos_rect-xpos_circ ?!

or

if (ypos_rect<ypos_circ && xpos_rect < xpos_cir)

Reply With Quote
  #4  
Old August 31st, 2006, 01:35 AM
Hugh of Borg's Avatar
Hugh of Borg Hugh of Borg is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Location: Switzerland
Posts: 1,152 Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level)Hugh of Borg User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 19 h 1 m 52 sec
Reputation Power: 1900
I put some more time into it. The easiest way (from the code perspective) would be to create an Area object for both objects then use the "void intersect(Area)" method and test the object with "boolean isEmpty()" to see if they did collide. This might not be the most efficient way but it should work.

for more information i recommend this link.
Comments on this post
william_nagels agrees: it helped me so much
Viper_SB agrees: informative

Reply With Quote
  #5  
Old August 31st, 2006, 10:19 AM
william_nagels william_nagels is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Location: belgium
Posts: 116 william_nagels User rank is Private First Class (20 - 50 Reputation Level)william_nagels User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 7 h 2 m 45 sec
Reputation Power: 7
Send a message via MSN to william_nagels
Ow man thanks for the help I get it now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesGame Development > Java applets games

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap