diff options
Diffstat (limited to 'engine/components/Velocity.ts')
-rw-r--r-- | engine/components/Velocity.ts | 10 |
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; + } + } } |