From 5a55b5fa0c678ff03842d2adec8543e754546718 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Sat, 2 Apr 2022 16:04:13 -0600 Subject: Grid system & simple physics --- src/entities/entity.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/entities/entity.js') diff --git a/src/entities/entity.js b/src/entities/entity.js index 33d1031..1eb5223 100644 --- a/src/entities/entity.js +++ b/src/entities/entity.js @@ -5,13 +5,14 @@ game.Entity = (id=game.nextId++) => { const addComponent = (component) => { components[component.name] = component; - } - const removeComponent = (component) => { - delete components[component.name]; - } - const hasComponent = (component) => { - components[component.name] !== undefined; - } + }; + const hasComponent = (componentName) => components[componentName] !== undefined; + const removeComponent = (componentName) => { + if (hasComponent(componentName)) { + delete components[componentName]; + } + }; + return { id, -- cgit v1.2.3-70-g09d2