question about how to handle collision in a game i'm working

Put your problem here if it does not fit any of the other categories.

question about how to handle collision in a game i'm working

Postby geoffrey » Mon Jan 12, 2009 9:07 am


disclaimer: the only coding I've done so far, is in school dealing with output in a command line :-p

I'm figuring out this opengl one step at a time. right now I'm trying to figure out how to handle 'collisions' with objects.

I have a class of 'rectangle' that keeps track of the coordinates of the corners of a rectangle,

and i have a ball, which is really more of an octagon made of 3 rectangles like so: Image

and then i have blocks that have just one rectangle on top of them.

what i need is the ball to move fairly fast (like 3-5 units/draw) and then stop when it comes in contact with a rectangle.

so, if i check for intersection the ball will sometimes go into the block and then suddenly pop back out of the block, which doesn't look right.

my idea is that i will have a collision function that always looks 3-5(depending on what speed i go with) units ahead to check for a future collision. but if the ball is traveling 5units/draw and it sees a block 2 units away should i just move the ball 2 more units?

again, this is the first time I've had to make a game, I'm just trying to nail down the design here. thanks in advance for any help.
Posts: 2
Joined: Sat Dec 13, 2008 2:36 am


Postby MrSnowflake » Mon Jan 12, 2009 12:08 pm

There are many ways to go about collision detection. You are better off on a game forum, or search google for collision detection.
User avatar
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby ErnestoGuevara » Mon Jan 12, 2009 5:19 pm

...but after you visit those game forums do come back and let us know how you did it...

Experienced Developer
Experienced Developer
Posts: 75
Joined: Thu Jan 08, 2009 2:02 am

Postby r0b3rt2 » Mon May 25, 2009 6:07 pm

Hi, i've had the same problem too.

try to look here ... ?lesson=30
Once Poster
Once Poster
Posts: 1
Joined: Tue Aug 05, 2008 6:54 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 11 guests