I'm trying to write something I believe is straightforward but wanted to check that I'm doing it right.
All I want is to update the position of a 2D sprite based an acceleration and velocity. I'm using time based modelling so I have time deltas at my disposal. My current approach looks a little like this:
int rotDuration = btnRight.GetDuration() - btnLeft.GetDuration(); ship.Facing += (ANGULAR_VELOCITY * (rotDuration)); //angular displacement (rads?) Rise::Vector2D forwardDir(sin(ship.Facing), cos(ship.Facing)); Rise::Vector2D finalVelocity = ship.Velocity + (elapsedTime * btnAcc.GetDuration() * MAX_ACC * forwardDir); ship.Position += finalVelocity;
Hopefully that's pretty straightforward. I get the duration that rotation was occurring for, then multiply this by the speed I wish to allow my ships to rotate. For the velocity, I applied the equation from here. I'm very unsure as to why it says to scale the whole thing by max acceleration, though...
Does this look correct and will it produce the sort of rotation you would expect? For context I'm simulating space- or ice-like inertia.