Jump to content
  • Advertisement
Sign in to follow this  
jordos

2D overhead space shooter help

This topic is 2998 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sorry if a similar question has already popped up here, but I'm trying to figure out a way to calculate the 'roll' of a 2D starship as it turns. I've got a bunch of frames for each starship depicting each angle and varying stages of 'roll', like this:
http://users.telenet.be/V776822/wbroll.png
(stolen from subspace aka continuum *blush*)
The closest I got was adding/deducting to/from a roll variable while the player was both thrusting and turning and continually moving that var back to 0 at a slower pace. However, when the player would thrust forward, stop holding the thrust button and then turn (I'm using friction-less space physics), stop turning and finally thrust again the ship would change direction without rolling at all! Something more advanced is needed and any help would be appreciated!
I'm programming in Blitz Basic btw.

edit: how can I add a link or img tag?

Share this post


Link to post
Share on other sites
Advertisement
The "something more advanced" you need is simply full physics simulation instead of part simulation and part ad-hoc animations that simply don't fit.

Or maybe you should adjust your expectations: airplanes roll naturally when they turn as a result of aerodynamic forces, but in zero gravity with no attrition turning and movement are decoupled, and "rolling" is a deliberate maneuver that a starship with a specific main engine configuration (e.g. rear center above and below, or three in an equilateral triangle) and suitable auxiliary engines can use to better align a direction in which the main engines can exert a lot of torque (presumably up/down or oblique) with the direction in which it wants to turn, in order to turn faster.
Many plausible engine configurations, e.g. one rear left and one rear right, would have no reason to roll, and spinning on any axis without thrusting forward is useful and perfectly natural.

If you want to keep the appearance of rolling for aesthetic reasons, I think you should avoid ad-hoc variables, which can only misbehave, and increase the tilt with the instantaneous speed and curvature of the ship's 2D movement (i.e. in tight turns).

Share this post


Link to post
Share on other sites
Quote:
If you want to keep the appearance of rolling for aesthetic reasons, I think you should avoid ad-hoc variables, which can only misbehave, and increase the tilt with the instantaneous speed and curvature of the ship's 2D movement (i.e. in tight turns).


So how do I get the curvature of my ship? I'd need to keep track of it's previous position and then do some math stuff with the old and new position? :)

[Edited by - jordos on July 12, 2010 7:52:32 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by jordos
Quote:
If you want to keep the appearance of rolling for aesthetic reasons, I think you should avoid ad-hoc variables, which can only misbehave, and increase the tilt with the instantaneous speed and curvature of the ship's 2D movement (i.e. in tight turns).


So how do I get the curvature of my ship? I'd need to keep track of it's previous position and then do some math stuff with the old and new position? :)

Yes, you need three positions.
You can use the inverse of the radius of the circle through the latest, second latest and third latest positions of the ship, or the angles of the triangle they form.
Anything that decreases to 0 for three collinear positions and grows to infinity, or to some large value, for turning 180° is appropriate.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!