summaryrefslogtreecommitdiff
path: root/src/engine/entities/Sign.ts
diff options
context:
space:
mode:
authorLizzy Hunt <elizabeth.hunt@simponic.xyz>2024-03-11 16:22:06 -0600
committerLizzy Hunt <elizabeth.hunt@simponic.xyz>2024-03-11 16:22:06 -0600
commit32879581e53fae5e684c24b44433172d8375d69e (patch)
tree307551e59409c2f01168e5fabeff200319c18aa7 /src/engine/entities/Sign.ts
parent4da17f6dedb4475c7730bdeab9ad3e339f0bfdee (diff)
downloadthe-abstraction-engine-32879581e53fae5e684c24b44433172d8375d69e.tar.gz
the-abstraction-engine-32879581e53fae5e684c24b44433172d8375d69e.zip
support underscores in function application, add sign entity
Diffstat (limited to 'src/engine/entities/Sign.ts')
-rw-r--r--src/engine/entities/Sign.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/engine/entities/Sign.ts b/src/engine/entities/Sign.ts
new file mode 100644
index 0000000..a11fba6
--- /dev/null
+++ b/src/engine/entities/Sign.ts
@@ -0,0 +1,49 @@
+import { Entity, EntityNames, makeLambdaTermHighlightComponent } from ".";
+import { BoundingBox, Colliding, Grid, Sprite } from "../components";
+import { IMAGES, SPRITE_SPECS, SpriteSpec, Sprites } from "../config";
+import { Coord2D } from "../interfaces";
+
+export class Sign extends Entity {
+ private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
+ Sprites.SIGN
+ ) as SpriteSpec;
+
+ private text: string;
+
+ constructor(text: string, gridPosition: Coord2D) {
+ super(EntityNames.Sign);
+ this.text = text;
+
+ const dimension = {
+ width: Sign.spriteSpec.width,
+ height: Sign.spriteSpec.height,
+ };
+
+ this.addComponent(
+ new Sprite(
+ IMAGES.get(Sign.spriteSpec.sheet)!,
+ { x: 0, y: 0 },
+ dimension,
+ Sign.spriteSpec.msPerFrame,
+ Sign.spriteSpec.frames
+ )
+ );
+
+ this.addComponent(
+ new BoundingBox(
+ {
+ x: 0,
+ y: 0,
+ },
+ dimension,
+ 0
+ )
+ );
+
+ this.addComponent(new Grid(gridPosition));
+
+ this.addComponent(new Colliding());
+
+ this.addComponent(makeLambdaTermHighlightComponent(this, this.text));
+ }
+}