summaryrefslogtreecommitdiff
path: root/engine/components/Velocity.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-12 13:49:16 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-12 13:49:16 -0600
commitc6e9baa0009f7cce0f6ff156a3957ef04a8cb684 (patch)
tree9766a4a33ad1c86aa71a5f92daf8917f3e5f5eed /engine/components/Velocity.ts
parentb67ffb57c1bf6e9628339a3f43c71ccebdb46136 (diff)
downloadjumpstorm-c6e9baa0009f7cce0f6ff156a3957ef04a8cb684.tar.gz
jumpstorm-c6e9baa0009f7cce0f6ff156a3957ef04a8cb684.zip
the great engine refactor
Diffstat (limited to 'engine/components/Velocity.ts')
-rw-r--r--engine/components/Velocity.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/engine/components/Velocity.ts b/engine/components/Velocity.ts
index 119427d..068d8cd 100644
--- a/engine/components/Velocity.ts
+++ b/engine/components/Velocity.ts
@@ -6,10 +6,18 @@ export class Velocity extends Component {
public dCartesian: Velocity2D;
public dTheta: number;
- constructor(dCartesian: Velocity2D, dTheta: number) {
+ constructor(dCartesian: Velocity2D = { dx: 0, dy: 0 }, dTheta: number = 0) {
super(ComponentNames.Velocity);
this.dCartesian = dCartesian;
this.dTheta = dTheta;
}
+
+ public add(velocity?: Velocity) {
+ if (velocity) {
+ this.dCartesian.dx += velocity.dCartesian.dx;
+ this.dCartesian.dy += velocity.dCartesian.dy;
+ this.dTheta += velocity.dTheta;
+ }
+ }
}