diff options
| author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-07-19 20:38:24 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-07-19 20:38:24 -0700 |
| commit | 0fd9fb097552686f2257c1aa689d797e80057bd1 (patch) | |
| tree | b8d0367bf7b62c049af60ace301ce1cffc08d821 /client/lib/entities/Floor.ts | |
| download | jumpstorm-0fd9fb097552686f2257c1aa689d797e80057bd1.tar.gz jumpstorm-0fd9fb097552686f2257c1aa689d797e80057bd1.zip | |
initial commit
Diffstat (limited to 'client/lib/entities/Floor.ts')
| -rw-r--r-- | client/lib/entities/Floor.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/client/lib/entities/Floor.ts b/client/lib/entities/Floor.ts new file mode 100644 index 0000000..d51badc --- /dev/null +++ b/client/lib/entities/Floor.ts @@ -0,0 +1,31 @@ +import { IMAGES, SPRITE_SPECS, Sprites, type SpriteSpec } from "../config"; +import { BoundingBox, Sprite } from "../components"; +import { TopCollidable } from "../components/TopCollidable"; +import { Entity } from "../entities"; + +export class Floor extends Entity { + private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(Sprites.FLOOR); + + constructor(width: number) { + super(); + + this.addComponent( + new Sprite( + IMAGES.get(Floor.spriteSpec.states[width].sheet), + { x: 0, y: 0 }, + { width, height: Floor.spriteSpec.height }, + Floor.spriteSpec.msPerFrame, + Floor.spriteSpec.frames + ) + ); + + this.addComponent( + new BoundingBox( + { x: 300, y: 300 }, + { width, height: Floor.spriteSpec.height } + ) + ); + + this.addComponent(new TopCollidable()); + } +} |
