From 2dc3120831fbcd03b635bbad59213ff0bf1f8879 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 13 Aug 2023 17:09:12 -0600 Subject: refactor velocity a bit for no real reason besides verbosity --- engine/systems/FacingDirection.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'engine/systems/FacingDirection.ts') diff --git a/engine/systems/FacingDirection.ts b/engine/systems/FacingDirection.ts index 4426ab6..daf639f 100644 --- a/engine/systems/FacingDirection.ts +++ b/engine/systems/FacingDirection.ts @@ -20,21 +20,24 @@ export class FacingDirection extends System { return; } - const totalVelocity: Velocity = new Velocity(); + const totalVelocityComponent = new Velocity(); const control = entity.getComponent(ComponentNames.Control); - const velocity = entity.getComponent(ComponentNames.Velocity); - totalVelocity.add(velocity); + const velocity = entity.getComponent( + ComponentNames.Velocity, + ).velocity; + + totalVelocityComponent.add(velocity); if (control) { - totalVelocity.add(control.controlVelocity); + totalVelocityComponent.add(control.controlVelocityComponent.velocity); } const facingDirection = entity.getComponent( ComponentNames.FacingDirection, ); - if (totalVelocity.dCartesian.dx > 0) { + if (totalVelocityComponent.velocity.dCartesian.dx > 0) { entity.addComponent(facingDirection.facingRightSprite); - } else if (totalVelocity.dCartesian.dx < 0) { + } else if (totalVelocityComponent.velocity.dCartesian.dx < 0) { entity.addComponent(facingDirection.facingLeftSprite); } }, -- cgit v1.2.3-70-g09d2