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 / [DBP] Gravity (Planetary)

Author
Message
Varg
20
Years of Service
User Offline
Joined: 14th Mar 2004
Location: N.W - EU - Highlands
Posted: 15th Mar 2004 04:17 Edited at: 15th Mar 2004 04:21
I'v been trying to make(only just begun, i'm stuck) a Gravity Force / Roketz / Bratwurst - clone of my own just for kicks and becouse I first figured it would be relativly easy .

I'm trying to make the physics-part but I can't seem to make it work as I want it to.

In this type of game i'm figuring you have two forces, first of the gravity whitch wants to pull everyting downward, and then the force outputted by the ships-thrusters and only after the thrust exeeds the power of the gravity will the ship be able to accelerate forward.

I mean I have it all finished in my head but I just can't seem to figure out in whitch end to start yet and I wondering if someone could give me some pointers.

What I'm really stuck on is the whole accelerate-part. Since gravity willhave to pull everyting down, the ship won't just stop when using thrusters but slow down as the thrust works against gravity and then begin it's journey forward. And if you cut the thrust the ship will again not just stop and go towards gravity since it had a momentum(whitch won't last though).

How would I go about in practice coding this?, the soft slowing down between gravitys pull and the momentum after thrust slowly getting lower and lower before the ship is again pulled down by gravity.

Hope all that rambling got through.


One more thing though, i'm a newbie and i'm comming from other languages where I rely heavily on Object and OO style programming(from c# to php even). HOW, does one go about applying gravity to more objects then only the ship I wanna control,

I mean, If I could use classes and such I could make a class(once I knew how to code the gravity part) a let it be used to handle everything in the game that needs to be controlled by gravity. But how, oh how does one work it out in dark basic ???.

I think i'm not used to thinking in Basic-ways.

Thanks in advance.
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 15th Mar 2004 07:14
Have an array that holds the downward pull of gravity for each object that can fall. The starting value is zero and each loop the value is increased by a constant amount unless countered by thrusters. Thrusters do not set the gravity value, they simply subtract from it. The value is then applied to the ship's position.

That's the basics. You can add some nice reality touches such as setting the pull to 9.8 units per second and using timer functions to see how much of that 9.8 units is applied. (9.8 / 1000 * miliseconds since last loop)
--
TAZ

Login to post a reply

Server time is: 2024-11-26 07:24:28
Your offset time is: 2024-11-26 07:24:28