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
Asteroids Velocity2D
Namespace: Asteroids
Assembly: Asteroids (in Asteroids.exe) Version: 1.1.1.0 (1.1.1)
Syntax
The Velocity2D type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Velocity2D | Initializes a new instance of the Velocity2D class |
Methods
Name | Description | |
---|---|---|
Accelerate |
Properties
Name | Description | |
---|---|---|
Velocity |
Remarks
Examples
[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