Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Bouncing, perhaps some Collision help as well.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Daetyrnis




PostPosted: Tue Apr 17, 2007 6:44 pm   Post subject: Bouncing, perhaps some Collision help as well.

I'm making one of those games which involve bouncing a ball of off some bricks, then your paddle, then the bricks, and so on.

I'm wondering what is the best way to simulate the ball bouncing off of the bricks, paddle, and walls. I would prefer not to just multiply the change in X or Y by -1, as that would result in very rigid bouncing. Could is somehow incorporate the speed of the paddle or something?

While I'm at it, I was thinking about how to make the game interesting, and I got the idea of the paddle being a shape other than, well, a paddle. For example, a triangular paddle. What is the most efficient way to detect collisions between a circle or oval and a polygon, such as a triangle.

Gah, have to go to dinner. If I need to elaborate on this, just say so.
*flies to the dinner table for some chili*
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Tue Apr 17, 2007 7:13 pm   Post subject: RE:Bouncing, perhaps some Collision help as well.

If it his an object that can move, just swap velocities. If it hits an object that can't move, multiply the velocity by -1. This works if all of the objects are the same mass. You are going to have to use some physics if you want it do be accurate when the objects have different masses.
Daetyrnis




PostPosted: Tue Apr 17, 2007 7:59 pm   Post subject: Re: Bouncing, perhaps some Collision help as well.

Thanks, that seemed to work for what I tried.

Now I'm really having troubles with detecting collisions. I looked at the tutorials in the proper section, and I've experimented a bit to no avail. I'm trying to detect a collision between a circle (the ball) and rectangles (the bricks, the wall, and the paddle which is a moving object)
Carey




PostPosted: Wed Apr 18, 2007 8:54 am   Post subject: Re: Bouncing, perhaps some Collision help as well.

Use Math.Disance. If the object is closer to the balls x, y coords + radius then you should have a collision.

You could also use whatdotcolour to check for spots all around the ball and do your collision procedure or whatever if the spots are anything but the background colour
richcash




PostPosted: Wed Apr 18, 2007 11:45 am   Post subject: Re: Bouncing, perhaps some Collision help as well.

There's a tutorial for determining a collision between a circle and a rectangle.

For a triangle and a circle, well, it's a bit tougher. You have to check if any of the sides of the polygon are inside of the circle using line-circle collision (which is in the tutorial). Then, you have to check if the center of the circle is inside of the triangle using point-polygon collision. (Or, you can check areas, which is a slower method).
Daetyrnis




PostPosted: Wed Apr 18, 2007 3:18 pm   Post subject: Re: Bouncing, perhaps some Collision help as well.

Carey @ Wed Apr 18, 2007 8:54 am wrote:
Use Math.Disance. If the object is closer to the balls x, y coords + radius then you should have a collision.

You could also use whatdotcolour to check for spots all around the ball and do your collision procedure or whatever if the spots are anything but the background colour


Math.Distance? (Doesn't seem to work). If you meant calculating the distance, then I gotcha. Wink I don't want to use whatdotcolour, as it only works for basic graphics and is rather undependable in my opinion.

richcash @ Wed Apr 18, 2007 11:45 am wrote:
There's a tutorial for determining a collision between a circle and a rectangle.

For a triangle and a circle, well, it's a bit tougher. You have to check if any of the sides of the polygon are inside of the circle using line-circle collision (which is in the tutorial). Then, you have to check if the center of the circle is inside of the triangle using point-polygon collision. (Or, you can check areas, which is a slower method).

I've already looked at your tutorials there, but thanks for helping. ^_^


I'm going to just go through collision step by step on my own, and I'll see where that gets me. If that doesn't work, I'll read richcash's tutorials again, so hopefully my problems are solved. ^_^
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: