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 / Zero-G (Frictionless) motion any examples and/or tutorials

Author
Message
DarrylKev
22
Years of Service
User Offline
Joined: 5th Nov 2002
Location:
Posted: 25th Nov 2002 21:26
Hello

Folks I am running into a brick wall here. I am trying to find some examples and/or tutorials on how to do Zero-G (FricitionLess) motion in a Dark Basic Made FPS Space Sim. I know it can be done because I have heard/read discussing it in some Visual Basic forums (without coding examples), but after finding DB I figured it would be shown or given some clues how to do (CODE) it.

Note, I have seen that a few of the asteroids type DB Games use it (at least I think they do) so I think it has and can be done.

So, Any help, pointers or directions to same, WOULD BE GREATLY APPRECIATED!!!!!!!!!!!!

DarrylKev
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 26th Nov 2002 00:11
To do frictionless motion, you need to think about two things, the applied thrust and the direction the object is actually moving. You'll need to make a thrust variable which holds the magnitude of the thrust, and you'll also need to know which way you are facing, since the example I'm doing is 2d you'll only need a y angle, making things much easier. Due to the simple laws of acceleration (F=ma, v=u+at) you can add the thrust directly to your velocity, with some time or mass constant if necessary. I do this by splitting up the thrust into x and y values (with sin and cos), and adding these to the x and y velocities respectively. After all that, here's some sample code:



Use the arrowkeys to move the cube around. Actual frictionless motion is not particularly nice, so you might want to put some coefficients in there to lower the speed.
DarrylKev
22
Years of Service
User Offline
Joined: 5th Nov 2002
Location:
Posted: 26th Nov 2002 23:27
Hello The Darthster and Group

Thanks for the Snippet. Now I see a way out of my dilemma. All I have to stood is figure out the way to add third dimension movement and then fix the left turn crash and then ...................!!! Oh well you get the idea.

Thanks Again

DarrylKev

TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 27th Nov 2002 11:00
You could also use Pitch, Roll and Turn object to steer the object, then using move object to make the thrust.

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
DarrylKev
22
Years of Service
User Offline
Joined: 5th Nov 2002
Location:
Posted: 27th Nov 2002 18:54
Hello Group and "The Cyborg"

Thanks for the command hints. I tried placing the "turn" command into the code before I left for work this morning. Now the thing turns left and right but I can't get it to thrust in the direction of the turn, just in the original direction of travel. However I don't think it will be that difficult to fix.

Again Thanks for the hint.

DarrylKev

TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 28th Nov 2002 09:45
Just use the "Move Object" command. As far as I know It will make the object move in the direction it's facing. Correct me if i'm wrong.

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
Paul J
22
Years of Service
User Offline
Joined: 6th Nov 2002
Location:
Posted: 28th Nov 2002 21:06
Ah, interesting post. I tried to do this a bit ago and although I was close something just wasn't right ... I tried it with x,y and z and it was close to being there. Now I've seen your code snippet I see what I did wrong (tho it was suprisingly similar).

The move object command moves u the way your facing yes, however, that means if your doing 30v in one direction, then turn the other way, you'll now go 30v in that direction - rather than carrying on floating off regardless of where your facing Afterall its only when your thrusting a force is in effect.

Cheers for the snippet,

Paul J

Login to post a reply

Server time is: 2024-11-23 18:19:10
Your offset time is: 2024-11-23 18:19:10