Public Group

# 2D overhead space shooter help

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

## 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.

##### Share on other sites
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 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 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 on other sites
OK, thanks for the help LorenzoGatti!

1. 1
2. 2
Rutin
20
3. 3
A4L
15
4. 4
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633738
• Total Posts
3013617
×