Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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 1544 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


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

This might help.

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.

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


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
Play Rimscape!    |    Play Conquer!
Offline tonberry1

Junior Devvie

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

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:
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
Play Rimscape!    |    Play Conquer!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

bilznatch (17 views)
2015-08-04 11:03:17

SHC (38 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (44 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (40 views)
2015-07-25 00:14:37

BurntPizza (48 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!