Skip to main content

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a =  F/m  // a Force will result in a smaller acceleration on objects with more mass
v += a    // acceleration is the rate of change in velocity
p += v    // velocity is the rate of change in position    

where:

a = acceleration, v = velocity, p = position
F = force, m = mass

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math. There is some sample code in that answer.

Also you can check out my asteroids demo, which implements the algorithm described above.

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a =  F/m  // a Force will result in a smaller acceleration on objects with more mass
v += a    // acceleration is the rate of change in velocity
p += v    // velocity is the rate of change in position    

where:

a = acceleration, v = velocity, p = position
F = force, m = mass

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math. There is some sample code in that answer.

Also you can check out my asteroids demo, which implements the algorithm described above.

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a =  F/m  // a Force will result in a smaller acceleration on objects with more mass
v += a    // acceleration is the rate of change in velocity
p += v    // velocity is the rate of change in position    

where:

a = acceleration, v = velocity, p = position
F = force, m = mass

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math. There is some sample code in that answer.

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a =  F/m  // a Force will result in a smaller acceleration on objects with more mass
v += a    // acceleration is the rate of change in velocity
p += v    // velocity is the rate of change in position    

where:

a = acceleration, v = velocity, p = position
F = force, m = mass

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math2D Spaceship movement math. There is some sample code in that answer.

Also you can check out my asteroids demo, which implements the algorithm described above.

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a =  F/m  // a Force will result in a smaller acceleration on objects with more mass
v += a    // acceleration is the rate of change in velocity
p += v    // velocity is the rate of change in position    

where:

a = acceleration, v = velocity, p = position
F = force, m = mass

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math. There is some sample code in that answer.

Also you can check out my asteroids demo, which implements the algorithm described above.

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a =  F/m  // a Force will result in a smaller acceleration on objects with more mass
v += a    // acceleration is the rate of change in velocity
p += v    // velocity is the rate of change in position    

where:

a = acceleration, v = velocity, p = position
F = force, m = mass

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math. There is some sample code in that answer.

Also you can check out my asteroids demo, which implements the algorithm described above.

added 205 characters in body
Source Link
Leftium
  • 4.4k
  • 3
  • 24
  • 30

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a =  F/m  // a Force will result in a smaller acceleration on objects with more mass
v += a    // acceleration is the rate of change in velocity
p += v    // velocity is the rate of change in position    

where:

F = force, m = mass
a = acceleration, v = velocity, p = position
F = force, m = mass

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math. There is some sample code in that answer.

Also you can check out my asteroids demo, which implements the algorithm described above.

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a = F/m
v += a
p += v

where:

F = force, m = mass
a = acceleration, v = velocity, p = position

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math. There is some sample code in that answer.

Also you can check out my asteroids demo, which implements the algorithm described above.

Instead of manipulating the velocity directly, add another variable: acceleration, that gradually, smoothly alters the velocity:

From classical physics (Newton's laws of motion):

a =  F/m  // a Force will result in a smaller acceleration on objects with more mass
v += a    // acceleration is the rate of change in velocity
p += v    // velocity is the rate of change in position    

where:

a = acceleration, v = velocity, p = position
F = force, m = mass

(Note m is the only scalar value; F, a, v, and p are all 2D or 3D vectors)

Also, there are actually two directions:

  1. The direction the ship is facing. Force from engines is applied along this vector.
  2. The direction the ship is actually moving (due to momentum). This is the velocity vector v.

I answered a related question on StackOverflow: 2D Spaceship movement math. There is some sample code in that answer.

Also you can check out my asteroids demo, which implements the algorithm described above.

added 94 characters in body
Source Link
Leftium
  • 4.4k
  • 3
  • 24
  • 30
Loading
added 5 characters in body
Source Link
Leftium
  • 4.4k
  • 3
  • 24
  • 30
Loading
typo
Source Link
Leftium
  • 4.4k
  • 3
  • 24
  • 30
Loading
Source Link
Leftium
  • 4.4k
  • 3
  • 24
  • 30
Loading