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 / ball bouncing

Author
Message
Gjl
20
Years of Service
User Offline
Joined: 28th Dec 2003
Location:
Posted: 10th Jan 2004 19:13
I'm trying to get a ball to bounce up and down but for some reason, after every bounce the ball gains velocity. How can I edit my code so that it keeps bouncing up to the same height?
Ianx
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location:
Posted: 10th Jan 2004 19:20
Take a look at my codebase posting here:
http://darkbasicpro.thegamecreators.com/?m=codebase_view&i=1e21455348816a141a9736ef42154b52

The basic principal being used is:
loop
for each particle
erase particle
position = position + velocity
velocity = velocity + acceleration
draw particle
end of particle loop
end of main loop


HTH

Rgds Ian.
Gjl
20
Years of Service
User Offline
Joined: 28th Dec 2003
Location:
Posted: 10th Jan 2004 20:28
Very nice, although a bit too complex for my needs.
I only want one ball to bounce without gaining or losing momentum.
I don't understand what you mean by the particles, I didn't see any mention of particles in the code.
Ianx
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location:
Posted: 10th Jan 2004 20:52
Particle = sphere or ball. Or whatever it is you're trying to bounce.

I've simplified my example to use just one ball and do nothing other than let it bounce.

Best of luck.
Ianx
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location:
Posted: 10th Jan 2004 20:52
(Press the SOURCE button on the previous message to see the amended code)
Ianx
20
Years of Service
User Offline
Joined: 10th Jan 2004
Location:
Posted: 10th Jan 2004 21:13
Or alternatively if you want the ball to bounce to the same height forever, see source on this message.
Gjl
20
Years of Service
User Offline
Joined: 28th Dec 2003
Location:
Posted: 10th Jan 2004 23:29
Thank you very much, this is a great help

Login to post a reply

Server time is: 2024-09-21 15:58:09
Your offset time is: 2024-09-21 15:58:09