diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/view/map.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/view/map.ts b/src/view/map.ts index 4e7fb20..c796c6f 100644 --- a/src/view/map.ts +++ b/src/view/map.ts @@ -58,14 +58,23 @@ function addSprite(builder: SpriteViewBuilder, tileset: Tileset, x: number, y: n builder.addSprite([x, y, x + 1, y + 1], tilePos); } -function buildMapLayer(r: Renderer, tileset: Tileset, layer: number[][]): SpriteView { +function buildMapLayer(r: Renderer, tileset: Tileset, layer: number[][]): MapLayerView { const builder = new SpriteViewBuilder(r, tileset.texture); for (let x = 0; x < layer[0].length; x++) for (let y = 0; y < layer.length; y++) addSprite(builder, tileset, x, y, layer[y][x]); - return builder.build(); + return new MapLayerView(builder.build()); +} + +class MapLayerView { + public constructor(private sprites: SpriteView) { + } + + public render(time: number): void { + this.sprites.render(); + } } export class MapView { @@ -77,11 +86,11 @@ export class MapView { return new MapView(layers); } - private constructor(private layers: SpriteView[]) { + private constructor(private layers: MapLayerView[]) { } - public render(time: number) { + public render(time: number): void { for (const layer of this.layers) - layer.render(); + layer.render(time); } } |