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.

Newcomers DBPro Corner / 2D Physics: Help?

Author
Message
Fneep
19
Years of Service
User Offline
Joined: 3rd Sep 2005
Location: In my house
Posted: 26th Jan 2006 05:24
Yeah, Hi.
I was wondering if anybody could explain to me in plain english, how to make a simple simulation of a bouncing ball? Ill code it myself after I know what to do in plain english.

TIA (Thanks in Advance)

Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 26th Jan 2006 22:00
You need to get you ball and have it accelerating upwards and a certain speed (Velocity) you then need the velocity to decrease slowly so say velocity was 10 you would be sending your object up in tens
you then decrease the velocity by 1 so the speed in which the ball is going up will slow down and eventully it will become a minus number, this means it will come back down.
You then need it so that when the ball hits the ground the velocity will then be set to one less than it was before in this case 9(there is a good reason)) the ball will go back up and the process will start again. The reason the velocity is set one lower than the one before it, is because this will make the ball eventually stop.

Hope this helps cause as I'm not actually coding as I go along I have only a vague idea of what I just said.

BM

Our aim is to keep the loo's clean, your aim can help.
Fneep
19
Years of Service
User Offline
Joined: 3rd Sep 2005
Location: In my house
Posted: 28th Jan 2006 07:18 Edited at: 28th Jan 2006 07:25
Yeah, actually, that was pretty helpful.
Though, when you say that you turn it down to 9 to make it bounce, then it would bounce ten times. Wouldnt it half its velocity? Then it would go to 5, then 2.5, then 1.25, then Id get sick of halving at put it at zero.
Oh, also, I would like to know how to make a simulation in which you hit a ball and it rebounds off the walls. Remember, plain english plz. I can do the collision.

General Sephiro
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location:
Posted: 28th Jan 2006 11:41 Edited at: 28th Jan 2006 11:43
*My 2 cents*
Ball Bouncing up and down...

Have a variable named Gravity# set it at what ever you want the gravity to be at.

Another variable for the Thrust or Bounce

The ball's Y setting will always be decreased by this something like
(Object Position Y(Ball)-Gravity#)+Bounce#
Then some where below this have the statement
If Bounce# > 0 then Bounce# = Bounce# - 1
Change it to suit ur own needs.

Obiviously having a statement so when it hits off the bottom of the screen / or the ground then Bounce# = 10 or what ever the desired bounce...

-------------------------------------------------------------

Bouncing off walls 2 ways to go about this that i know off.

You can either get the angle at which it's facing when it hits the wall and reverse it.

I usually do this by a finding out which direction it's moving, then flip it by 180 degrees hope that helps.. i remember doing something like this with my first pong game, pitty i had to reformat hard drive...

StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 28th Jan 2006 20:30 Edited at: 28th Jan 2006 20:33
Hi,

Try this code:
Its not mine (creds to Mark Fleury)


It helped me - and its a fun example!


You can look through it and still code it your own way. His rem statements explain the process.

Login to post a reply

Server time is: 2024-11-27 05:48:14
Your offset time is: 2024-11-27 05:48:14