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 / Coding Physics (Checking Scripting)

Author
Message
Pegasus Flight Resources
17
Years of Service
User Offline
Joined: 6th Oct 2006
Location: Vermont
Posted: 7th Oct 2006 05:12
I have been trying to figure out how to script/code jump physics in Dark BASIC, but I have come to almost no avail. Here is an example of the code I tried to make:


This code is to create the array with Y coordinates in order to use them later on in the main loop. I use the 'shiftkey()' function for jumping, but I haven't figured out whether this previous script is incorrect, and if not, then I know that my other script doesn't work.
Thank you in advance for your response(s).
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Oct 2006 20:46 Edited at: 7th Oct 2006 20:54
Hello,

If you actually want the physics of this, it's basically velocity change over time (acceleration) and distance change over time (velocity). If someone is jumping in place up and down, their legs give them a certain acceleration. Once they leave the ground, this acceleration is translated into velocity. Since we're mostly interested in what is happening when they leave the ground (the actual jump) we don't have to concentrate too much on the acceleration before the jump because we really only want that initial velocity when they leave the ground. If it is important to find out how much acceleration their legs applied to affect the velocity, we'd have to have a time interval for that buildup.

I'll skip that and assume the time interval is 1 so our initial velocity will equal our acceleration.

Now that we have our initial velocity, it is going to decrease because of gravity as the jumper goes up. They will continue to rise and slowdown at a deceleration rate = to gravity (-9.8) until their jumping velocity = 0. Once it equals zero, it will increase in the opposite direction at a rate = gravity (-9.8) until they hit the ground.

I put together an example of a perpetually bouncing ball. What I wrote above applies. I also included a bunch of general motion physics equations in the form of functions. They are variations of each other and can be applied according to what the situation calls for and what elements need to be solved for.




I calculate the acceleration and initial velocity based on the mass and the force I want to apply to the ball. Since I'm not building up speed, I set the time value equal to one when I calculate the initial velocity.

Then I take this velocity and plug it into the loop and calculate the new velocity (slowing down) due to gravity. I control time with the time# variable - the iterations of the loop are based on the values of the final velocity instead of time, so in a sense, time# is calculated based on what the final state of the object is instead of the other way around.

If you pick apart my loop, you will be able to tell how this sim isn't quite "real life". That's one good thing about computer sims, you only have to make it look like it's right!

Enjoy your day.

Login to post a reply

Server time is: 2024-05-22 11:16:32
Your offset time is: 2024-05-22 11:16:32