Velocity2D ClassDelta Engine Documentation
Component for any Entity moving around in 2D space with velocity limited to a maximum value It can be accelerated (or decelerated, which is the same) by a vector, by magnitude and direction, or by a scalar factor View code on GitHub
Inheritance Hierarchy

System Object
  Asteroids Velocity2D

Namespace: Asteroids
Assembly: Asteroids (in Asteroids.exe) Version: 1.1.1.0 (1.1.1)
Syntax

public class Velocity2D

The Velocity2D type exposes the following members.

Constructors

  NameDescription
Public methodVelocity2D
Initializes a new instance of the Velocity2D class
Top
Methods

  NameDescription
Public methodAccelerate
Top
Properties

  NameDescription
Public propertyVelocity
Top
Remarks

Tests: Asteroids.Tests.Velocity2DTests
Examples

4 unit tests call Asteroids.Velocity2D
[Test]
public void AccelerateByPoint()
{
    velocity.Accelerate(Point.One);
    Assert.AreEqual(Point.One, velocity.velocity);
}
[Test]
public void AccelerateByPointExceedingMaximum()
{
    velocity.Accelerate(new Point(6, 0));
    Assert.AreEqual(5, velocity.velocity.X);
    Assert.AreEqual(0, velocity.velocity.Y);
}
[Test]
public void AccelerateByMagnitudeAngle()
{
    velocity.Accelerate(4, 0);
    Assert.AreEqual(-4, velocity.velocity.Y);
    Assert.AreEqual(0, velocity.velocity.X);
}
See Also