Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  I want only 1 collision  (Read 1357 times)
0 Members and 1 Guest are viewing this topic.
Offline tonberry1

Junior Devvie





« Posted 2005-05-29 07:41:12 »

While reading this post, you might want to check this out (a picture about my problem)

So, Im programming a Volleyball game, where the user hits the ball from below or next to the ball.

In the picture if the user's green area and the ball collide, the ball should move to right and if the user's red area collide with the ball, the ball jumps up (and black is mix of these).

The problem is, that as the picture shows, I'd like to have the ball jump just up, not to the right. First the ball jumps up, yes, but the player goes still up and if/when the player is high enough, the ball's collision thinks I want the ball to go right too.

So, in short: any ideas how the collision detection in these kind of ball games is usually made? (or how the collision detection would ignore the green area if the ball is already on the red?)

edit: I figured that the program could store the "color" of the first collision to a variable and then ignore other collisions, but still the question remains, that how are those collisions usually handled?

-= Life is what you decide it to be - Solid Snake =-
Offline shmoove

Junior Devvie




Doh!


« Reply #1 - Posted 2005-05-29 07:58:17 »

This might help.

shmoove
Offline tonberry1

Junior Devvie





« Reply #2 - Posted 2005-05-29 12:50:25 »

I have been wondering that collision thing before and now after reading that article I know it, but it didnt help much to this current problem.

In that article (pool) the both balls will change their direction after the collision, but in my problem the player will continue its way up.

Of course I could make the player to fall down after touching the ball, but I'd like to use it only as the last resort.

-= Life is what you decide it to be - Solid Snake =-
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #3 - Posted 2005-05-29 15:20:56 »

May time stamp each ball-player collision on each player & disallow further collisions within a time limit.

1  
2  
3  
4  
5  
6  
7  
final static long DELAY = 100; // 100ms (say)
long now = System.currentTimeMillis();
// Some code & a loop to go round all the players here
if (collision && player[i].timeLastHit + DELAY < now) {
     player[i].timeLastHit = now;
     // Process collision here
}


Alan

Time flies like a bird. Fruit flies like a banana.
Offline Malohkan

Senior Devvie




while (true) System.out.println("WOO!!!!");


« Reply #4 - Posted 2005-05-29 21:12:38 »

What I do after collisions is move the object just out of range of the collision.  If you do that, you won't have to worry about them colliding again because the volleyball will be moving faster up than the player.

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline tonberry1

Junior Devvie





« Reply #5 - Posted 2005-05-30 15:30:43 »

Quote
What I do after collisions is move the object just out of range of the collision.

That sounds something I could use. Thx.

-= Life is what you decide it to be - Solid Snake =-
Offline Malohkan

Senior Devvie




while (true) System.out.println("WOO!!!!");


« Reply #6 - Posted 2005-05-30 21:25:13 »

here's another idea:
1  
2  
if (velocityZ < 0 && z < 1.0) //1.0 is where a collision is
   velocityZ = -velocityZ;

In this case, more than one collision does NOT get hit, because the sign of velocityZ is the first thing checked in the if statement.  So if you can determine a boolean for whether or not the ball is coming TOWARD the person, you can decide whether or not it's bouncing.  If it's coming toward and there's a collision, bounce it.  If it's going away and there's a collision, ignore it.

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (50 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (57 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!