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 Professional Discussion / Calculating new bullet position

Author
Message
Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 20th Jan 2012 17:22 Edited at: 20th Jan 2012 17:26
Hey all, I'm working on weapons for my 2d game (using 3d commands) at the moment and I'm having some issues with moving the bullets. The data I have to work with is as follows:

-Current bullet position
-Angle of travel
-Speed

I found a formula that I believe is supposed to do the trick, but I haven't had any luck getting it working. The formula was found on this website (look at the first reply), and it may just be an issue that I didn't convert the code to DBP properly. Here's my code:




NOTE: I'm using the Z value as the Y value in my game.

Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 20th Jan 2012 20:58
I don't think you need the '* con_PI / 180' bit in your formula as this converts the angle to radians. DBP already works in degrees so no convertion is necessary unlike C++ where the standard sin, cos and tan use radians and require convertion.

Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 20th Jan 2012 23:18
Try using the newvalue commands(newxvalue,newyvalue,newzvalue) instead. They use the exact formula that you're using, and is as easy as this:


Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 21st Jan 2012 06:22
@Dar13

Whaaaat? I had no idea those commands existed, that's awesome! Thanks for your help

Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 21st Jan 2012 15:59
Quote: "Whaaaat? I had no idea those commands existed, that's awesome! Thanks for your help"

That's how I felt when I first found them too.

Login to post a reply

Server time is: 2026-07-09 17:42:42
Your offset time is: 2026-07-09 17:42:42