summaryrefslogtreecommitdiff
path: root/src/entities/entity.js
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-04-01 17:12:37 -0600
committerLogan Hunt <loganhunt@simponic.xyz>2022-04-01 17:12:37 -0600
commit100bbecccbf7b5e09ee60d1c2934df09006344f1 (patch)
tree08d9fbc488b5b33066fac14bad1c02e72ecb0a2d /src/entities/entity.js
parent4cabba2561f55ee6d068d631e3272ff7bf984b37 (diff)
downloadbbiy-100bbecccbf7b5e09ee60d1c2934df09006344f1.tar.gz
bbiy-100bbecccbf7b5e09ee60d1c2934df09006344f1.zip
Fix sprites
Diffstat (limited to 'src/entities/entity.js')
-rw-r--r--src/entities/entity.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/entities/entity.js b/src/entities/entity.js
new file mode 100644
index 0000000..33d1031
--- /dev/null
+++ b/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 removeComponent = (component) => {
+ delete components[component.name];
+ }
+ const hasComponent = (component) => {
+ components[component.name] !== undefined;
+ }
+
+ return {
+ id,
+ components,
+ addComponent,
+ removeComponent,
+ hasComponent
+ };
+} \ No newline at end of file