diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-11-17 13:38:09 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-11-17 13:38:09 +0100 |
commit | 49699eeb453b3ea8b934a6a69795e9db26d523c3 (patch) | |
tree | 41bc647d4b6b15129188a9fe8f28ce27f6e85560 /src | |
parent | 0db19bd11958cbead28cc5aad94d80a277f80290 (diff) | |
download | rpgedit-49699eeb453b3ea8b934a6a69795e9db26d523c3.tar rpgedit-49699eeb453b3ea8b934a6a69795e9db26d523c3.zip |
MapView: add class for layer rendering
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); } } |