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 / 2D shooting in any direction

Author
Message
Lonnehart
15
Years of Service
User Offline
Joined: 17th Apr 2009
Location:
Posted: 23rd May 2009 09:13
I haven't coded this yet, but I've been trying to wrap my brain around a formula that will do this;

In the game I'm working on, your ship's guns follow the mouse cursor (and your ship spins accordingly). I'd like to know the best way to get the bullet from my ship's guns to the location of the mouse cursor that's recorded the moment the fire button is pressed. Any ideas?
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 23rd May 2009 15:10
with the command "atanfull" you can calculate the angle from your ship to your mouse pointer. then you'll be able to work out the bullets too i think

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 24th May 2009 00:44 Edited at: 24th May 2009 00:47
Working in 3d is the easiest way to do this, even if it's a 2d game. I'm making a 2d game with this system.



This is bare bones and probably not optimized. Add all the bells and whistles you want. Set the object collision to detect within a fixed range of enemy objects, whatever you want.

This version puts the projectile on the same depth as the target.

Lonnehart
15
Years of Service
User Offline
Joined: 17th Apr 2009
Location:
Posted: 24th May 2009 06:03 Edited at: 24th May 2009 11:25
Getting the angle is one thing. I'd also like to get the bullet to it's target. It's gonna be a headache having to calculate the route for each and every projectile since players love rapid fire weapons.

-edit-
I just found this code in this post...
http://forum.thegamecreators.com/?m=forum_view&t=101282&b=7




From what I'm seeing, I could get the angle first, then use the Move Sprite command to move the bullet forward to its target location?
Lonnehart
15
Years of Service
User Offline
Joined: 17th Apr 2009
Location:
Posted: 25th May 2009 00:59
Just another question... can you use ATANFULL to plot points at an angle towards the target coordinates, or rather to move an object forward at an angle?
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 25th May 2009 07:56
Yes you can! for your previous post! you can just use YRotate or whatever to make it point somewhere if you have the angle from ATANFull

Login to post a reply

Server time is: 2024-09-28 06:20:29
Your offset time is: 2024-09-28 06:20:29