News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Turning with elasticity

Started by gingerprince, October 06, 2006, 12:25:30 PM

Previous topic - Next topic

gingerprince

I have a 2D `ship` similar to that in the game Asteroids.
I can move the ship at any given `angle` at a variable `velocity`by using the formula:-

deltax# = velocity *cos(angle)
deltay# = velocity *sin(angle)

The velocity is calculated with acceleration and friction so is not a constant velocity.

As in Asteroids I want to turn the ship so there is an `elastic` turning effect ( like a handbrake turn)

Any suggestions please?

Many thanks.

stef


I made a techdemo named "elastical vehicle movement" some times ago. You'll find it in showcase folder.
Maybe that's interesting for you.


Cheeslord

#2
I would recommend replacing Velocity with seperate variables for x and y velocity, so every frame

x=x+vx
y=y+vy

and then, when the player thrusts,
vx=vx+(thrust*cos(angle))
vy=vy+(thrust*sin(angle))

Mark.

edit (it goes without saying dont use integer variables, I am just writing the concept rather than correct syntax)