aboutsummaryrefslogtreecommitdiff
path: root/static/src/engine/entity.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth@simponic.xyz>2024-09-07 20:20:07 -0700
committerElizabeth Hunt <elizabeth@simponic.xyz>2024-09-12 17:23:30 -0700
commit8ec7f5368232d59f344e1067e1bad5e48dbcb7ae (patch)
tree1ad2df4dc00773f2307d1525cc80ac7410ea8fba /static/src/engine/entity.ts
parente4e31978bae7e45be57b376415a4b925ac8cbc03 (diff)
downloadkennel.hatecomputers.club-8ec7f5368232d59f344e1067e1bad5e48dbcb7ae.tar.gz
kennel.hatecomputers.club-8ec7f5368232d59f344e1067e1bad5e48dbcb7ae.zip
get "cats" up there
Diffstat (limited to 'static/src/engine/entity.ts')
-rw-r--r--static/src/engine/entity.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/static/src/engine/entity.ts b/static/src/engine/entity.ts
new file mode 100644
index 0000000..2c8d38e
--- /dev/null
+++ b/static/src/engine/entity.ts
@@ -0,0 +1,45 @@
+import {
+ Component,
+ ComponentType,
+ PositionComponent,
+ RenderableComponent,
+ TrailingPositionComponent,
+} from "./component";
+
+export enum EntityType {
+ LASER = "LASER",
+ CAT = "CAT",
+}
+
+export interface Entity {
+ entity_type: EntityType;
+ id: string;
+ components: Record<ComponentType, Component>;
+}
+
+export const create_laser = (base: Entity) => {
+ const trailing_position: TrailingPositionComponent = {
+ name: ComponentType.TRAILING_POSITION,
+ trails: [],
+ };
+ base.components[ComponentType.TRAILING_POSITION] = trailing_position;
+
+ const renderable: RenderableComponent = {
+ name: ComponentType.RENDERABLE,
+ };
+ base.components[ComponentType.RENDERABLE] = renderable;
+ return base;
+};
+
+export const create_cat = (base: Entity) => {
+ const renderable: RenderableComponent = {
+ name: ComponentType.RENDERABLE,
+ };
+ base.components[ComponentType.RENDERABLE] = renderable;
+ base.components[ComponentType.POSITION] = {
+ component: ComponentType.POSITION,
+ x: Math.random() * 1_000,
+ y: Math.random() * 1_000,
+ } as unknown as PositionComponent; // TODO: hack
+ return base;
+};