|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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! |
|
#3
|
|||
|
|||
|
and how would i do that :s
Quote:
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) |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
Ow man thanks for the help I get it now.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Game Development > Java applets games |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|