diff options
| author | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-07-02 11:55:17 -0700 |
|---|---|---|
| committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-07-02 11:55:17 -0700 |
| commit | 6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 (patch) | |
| tree | ed97e39ec77c5231ffd2c394493e68d00ddac5a4 /Homework/cs5410/bbiy/src/entities/entity.js | |
| download | misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.tar.gz misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.zip | |
Diffstat (limited to 'Homework/cs5410/bbiy/src/entities/entity.js')
| -rw-r--r-- | Homework/cs5410/bbiy/src/entities/entity.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Homework/cs5410/bbiy/src/entities/entity.js b/Homework/cs5410/bbiy/src/entities/entity.js new file mode 100644 index 0000000..3da032c --- /dev/null +++ b/Homework/cs5410/bbiy/src/entities/entity.js @@ -0,0 +1,23 @@ +game.nextId = 0; + +game.Entity = (id=game.nextId++) => { + const components = {}; + + const addComponent = (component) => { + components[component.name] = component; + }; + const hasComponent = (componentName) => components[componentName] !== undefined; + const removeComponent = (componentName) => { + if (hasComponent(componentName)) { + delete components[componentName]; + } + }; + + return { + id, + components, + addComponent, + removeComponent, + hasComponent + }; +}
\ No newline at end of file |
