2023-08-25 18:48:17 -04:00
|
|
|
import { IMAGES, SPRITE_SPECS, Sprites, type SpriteSpec } from '../config';
|
|
|
|
import { BoundingBox, Sprite } from '../components';
|
|
|
|
import { TopCollidable } from '../components/TopCollidable';
|
|
|
|
import { Entity, EntityNames } from '../entities';
|
2023-07-19 23:38:24 -04:00
|
|
|
|
|
|
|
export class Floor extends Entity {
|
2023-08-12 15:49:16 -04:00
|
|
|
private static spriteSpec: SpriteSpec = SPRITE_SPECS.get(
|
2023-08-25 18:48:17 -04:00
|
|
|
Sprites.FLOOR
|
2023-08-12 15:49:16 -04:00
|
|
|
) as SpriteSpec;
|
2023-07-19 23:38:24 -04:00
|
|
|
|
|
|
|
constructor(width: number) {
|
2023-08-23 21:44:59 -04:00
|
|
|
super(EntityNames.Floor);
|
2023-07-19 23:38:24 -04:00
|
|
|
|
|
|
|
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-25 18:48:17 -04:00
|
|
|
Floor.spriteSpec.frames
|
|
|
|
)
|
2023-07-19 23:38:24 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
this.addComponent(new TopCollidable());
|
|
|
|
}
|
|
|
|
}
|