From 06bb4177202b432d5f42141975ec82b5a8837f0e Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sat, 2 Mar 2024 02:22:46 -0700 Subject: slight refactor in collision behavior --- src/engine/systems/Render.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/engine/systems/Render.ts') diff --git a/src/engine/systems/Render.ts b/src/engine/systems/Render.ts index 7cb5d81..83daa52 100644 --- a/src/engine/systems/Render.ts +++ b/src/engine/systems/Render.ts @@ -1,5 +1,5 @@ import { System, SystemNames } from "."; -import { BoundingBox, ComponentNames, Sprite } from "../components"; +import { BoundingBox, ComponentNames, Highlight, Sprite } from "../components"; import { Game } from ".."; import { clamp } from "../utils"; import { DrawArgs } from "../interfaces"; @@ -43,8 +43,13 @@ export class Render extends System { center: boundingBox.center, dimension: boundingBox.dimension, rotation: boundingBox.rotation, - tint: entity.hasComponent(ComponentNames.Highlight) ? "red" : undefined, }; + if (entity.hasComponent(ComponentNames.Highlight)) { + const highlight = entity.getComponent( + ComponentNames.Highlight, + ); + drawArgs.tint = highlight.isHighlighted ? "red" : undefined; + } sprite.draw(this.ctx, drawArgs); }); -- cgit v1.2.3-70-g09d2