Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Bouncing Equation

Author
Message
Spiderman
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location: Canada
Posted: 26th Jul 2003 22:32
I want to make a 3D Pong game (similar to this one: [href]www.addictinggames.com/3dpong.html[/href]), but I need to know how to get the ball to bounce of the paddle at a realistic angle.
Attreid
22
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 27th Jul 2003 00:08
you need to move your ball with 3 speeds
one speed for the axe X, and the two others .. guess
then, if the ball hit the left or the right wall, you just have to change the speed that move the ball left/right : speed = speed * (-1)
the same for the axe UP DOWN

"He will come...the voice from the outer world,
bringing the holy war, the Jihad, which will cleanse the Universe and bring us out of darkness."
Furiousuk
22
Years of Service
User Offline
Joined: 10th Jan 2003
Location: United Kingdom
Posted: 27th Jul 2003 15:13
Here's some source of a 3D bouncing ball. Uses the method Attreid explained.
Drifter
21
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 28th Jul 2003 06:11
What you do is the angle that the ball hits the wall at is the angle that it will bounce off at.

\ / Like here the angle is 10 so the bouncing anlge will be 10
\ /
10\/10
========

"Sun makes me sneeze but thats a different story"
Ag3ntSm1th
22
Years of Service
User Offline
Joined: 13th May 2003
Location:
Posted: 28th Jul 2003 07:31
attreid has the easiest way... i made a pong game like 8 years ago in qbasic and thats how i did it. works perfect

"The secret to creativity is knowing how to hide your sources." - Einstein
my DarkBasic creations - http://www.sixurbanninjas.tk
Spiderman
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location: Canada
Posted: 28th Jul 2003 21:45
Thanks!
Magpie
21
Years of Service
User Offline
Joined: 16th Jul 2003
Location: Otherland! Cos it rocks!
Posted: 28th Jul 2003 22:52
Anyone know how to make a charactor jump?
My jumps always look kinda triangular.

Ag3ntSm1th
22
Years of Service
User Offline
Joined: 13th May 2003
Location:
Posted: 29th Jul 2003 01:32
stick him in the cornhole with a red hot poker

"The secret to creativity is knowing how to hide your sources." - Einstein
my DarkBasic creations - http://www.sixurbanninjas.tk
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 29th Jul 2003 02:17
Few comments.

While the bounce method you're all speaking of works fine for a pong game, it should be noted that this is not the way a real ball will behave in the physical world, so don't use it for a minigolf game or anything like that.

Jumping: It sounds like you have two states: going up and going down. In reality, you need to deal with velocity and gravitational acceleration. A jump should give a positive (upward) y-velocity. Each game cycle, you should move the player in the y direction by the y-velocity value, but also every cycle subtract from the y-velocity value by your gravitational constant. The numbers take playing around with, but this is how you can get parabolic jumping motion.

Magpie
21
Years of Service
User Offline
Joined: 16th Jul 2003
Location: Otherland! Cos it rocks!
Posted: 29th Jul 2003 18:25
Damn that's clever. You're always lightyears ahead of me HellMonkey.

Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 30th Jul 2003 05:06
All in a day's work.

Trowbee
22
Years of Service
User Offline
Joined: 12th Apr 2003
Location: United Kingdom
Posted: 30th Jul 2003 05:52
I hate yet to try it, but it seems like a good idea in my head, and its trying to remember advanced maths which I havent done in ages.

If you use cos, it creates a smooth arc. So using cos(variable) where you want to jump, it should work. However, cos ranges from +1 to -1, so use cos*100 or something
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 30th Jul 2003 07:23
Sorry there, a constant acceleration means a constant change in velocity and thus a parabolic change in position. This comes straight from calculus:

If your acceleration is -10 (generic units):
Velocity = Integral( Acceleration )
Velocity = S( -10 dx ) = -10x

Position = Integral( Velocity )
Position = S( -10x dx) = -5x^2

-5x^2 is parabolic and describes the position due to gravitational acceleration.

Login to post a reply

Server time is: 2025-05-19 17:04:26
Your offset time is: 2025-05-19 17:04:26