jumpstorm/engine/entities/Floor.ts

34 lines
886 B
TypeScript
Raw Normal View History

2023-07-19 23:38:24 -04:00
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 {
2023-08-12 15:49:16 -04:00
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
Sprites.FLOOR,
) as SpriteSpec;
2023-07-19 23:38:24 -04:00
constructor(width: number) {
super();
this.addComponent(
new Sprite(
2023-08-12 15:49:16 -04:00
IMAGES.get((Floor.spriteSpec?.states?.get(width) as SpriteSpec).sheet),
2023-07-19 23:38:24 -04:00
{ x: 0, y: 0 },
{ width, height: Floor.spriteSpec.height },
Floor.spriteSpec.msPerFrame,
2023-08-12 15:49:16 -04:00
Floor.spriteSpec.frames,
),
2023-07-19 23:38:24 -04:00
);
this.addComponent(
new BoundingBox(
{ x: 300, y: 300 },
2023-08-12 15:49:16 -04:00
{ width, height: Floor.spriteSpec.height },
),
2023-07-19 23:38:24 -04:00
);
this.addComponent(new TopCollidable());
}
}