This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Help with Collision Detection


Help with Collision Detection

Postby markhsch » Nov 27, 2003 @ 12:50am

Ok, I give up. This should be so easy, but for the life of me can't figure out the best method. Basically, think of a single stationary block and a bouncing ball (ala Araknoids). I need to determine if the ball should reverse Y direction if it hits on the top or reverse X direction if it hits the block on the side. My basic game loop is:

1) Render ball
2) Animate ball (applies x and y speed to x&y vals)
3) Go through blocks and see if ball has collided

It's step 3 that is messing up. I seem to find collisions from top or bottom find (ptIntersect.y is equal to the top or bottom coord of block), but the side collision is giving me problems.

Here are some images.

1) This shows the CollisionMask sample with graphics changed to look like what I am using. This is the ball hitting the block from the top. Note that the ball overlaps the block. This is because the Y speed is set to something like 5 pixels so it has the possibility of overlapping by at most 4 pixels (I move it to the top edge if a collision is detected, but collision detection occurs with overlapping).

Image

2) This shows the same example with the ball coming from the right. Things to notice: the SpriteCollision Y value is the same in 2nd image as first so I can't use that to determine which direction I should bounce the ball.

Image

Well, I hope this post made sense. Any help I can get I'd really appreciate.

Oh, and no, the game I am working on is not another breakout/araknoid clone. Something entirely different.

-Mark
markhsch
 


Postby ppcStudios » Nov 27, 2003 @ 12:56am

Is it possible for you to use the direction vector of the ball's motion to determine the resulting direction after the collision?
G.R. Moore
President/CEO
Pocket PC Studios
www.ppcstudios.com

Image
User avatar
ppcStudios
pm Insider
 
Posts: 744
Joined: Aug 23, 2002 @ 3:53pm
Location: Canfield, Ohio


Clarification

Postby markhsch » Nov 27, 2003 @ 12:59am

markhsch
 


Code and Binaries

Postby markhsch » Nov 27, 2003 @ 1:04am

markhsch
 


Whoops

Postby markhsch » Nov 27, 2003 @ 1:07am

markhsch
 


Postby ppcStudios » Nov 27, 2003 @ 4:17am

G.R. Moore
President/CEO
Pocket PC Studios
www.ppcstudios.com

Image
User avatar
ppcStudios
pm Insider
 
Posts: 744
Joined: Aug 23, 2002 @ 3:53pm
Location: Canfield, Ohio


Postby mlepage » Nov 27, 2003 @ 11:36pm

This issue is called "tunneling" if you wish to search for it.
www.scalenesoftware.com
Great games for your Palm and Pocket PC!
User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


Postby 8bit » Nov 29, 2003 @ 2:08am

8bit
pm Member
 
Posts: 8
Joined: Jul 6, 2003 @ 10:09am
Location: South Africa


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron