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 / Trigonometry question

Author
Message
NickH
16
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 24th May 2008 15:38
Hi. I'm working on a space game. I've just made progress with vectors, which almost made my brain melt. They're not easy to teach yourself!

Anyhoo. I've made my craft have some very simple physics so far. basically it moves around in space, but when I pitch up/down it goes up, then down up then down etc... Basically this calculation tells the ship where to point. It works perfectly when turning left or right. I've also got the same problem with my camera (basically the same code). What am I doing wrong with my trig?


SHIP.HDG.X = OBJECT POSITION X (2)+(20*(SIN(SHIP.A.X)))
SHIP.HDG.Y = OBJECT POSITION Y (2)+(20*(-SIN(SHIP.A.Y)))
SHIP.HDG.Z = OBJECT POSITION Z (2)+(20*(COS(SHIP.A.X)))
NickH
16
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 25th May 2008 15:06
Ok. I've re-thought my original code about a million times....or so it feels. This is getting annoying now! I've only been using DarkBASIC since last Saturday, so I'm not completely upto scratch yet!

Anybody know of a good way to make spaceship act like it has real thrusters? So when you fire a thruster it accelerates in that direction? but when you stop the thrusters it carries on drifting allowing you to point the ship in any direction and fire your thrusters again. Also I'd like to make it so you can control more than one direction of thrust. In other words fire thrusters to move on all 3 axis. On top of this also allow full rotation on all 3 axis too. If that makes sense!? I've been trying for a few days now with only small successes. Nothing seems to be working. If I get one thing right another thing goes wrong. I keep restarting my physics to try n get around the problem, but create a new one in the process. Any suggestions would be helpful!

Thanks
Nick
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th May 2008 05:48
The move command moves an object in the direction it is pointing - when you apply the thrusters you simply increase the velocity variable for it's movement.

As for rotation, that's a whole other bag of worms as DB uses Euler rotation.

I suggest you take a look at EZRotate. Thanks to Ron, it makes rotations in DB possible by humans who want to keep all of their hair!

And, there's a free version available too!...

http://www.gametoolshed.com/

TDK_Man

Jeff032
17
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 29th May 2008 16:39 Edited at: 29th May 2008 16:41
Here's some movement code from a space game I was working on:



Login to post a reply

Server time is: 2024-11-25 23:33:54
Your offset time is: 2024-11-25 23:33:54