From ec0e51231f95b4d847e4e94eb7146d3a0c159512 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 11 Nov 2018 20:31:22 +0100 Subject: Prepare support for adding extra elements to map layers --- src/controller/gamecontext.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/controller') diff --git a/src/controller/gamecontext.ts b/src/controller/gamecontext.ts index 9bb87e5..1595b41 100644 --- a/src/controller/gamecontext.ts +++ b/src/controller/gamecontext.ts @@ -39,7 +39,7 @@ export class GameContext implements CollidableGroup { ); } - private static async loadMap(renderer: Renderer, name: string): Promise<[SpriteView, Collidable[]]> { + private static async loadMap(renderer: Renderer, name: string): Promise<[SpriteView[], Collidable[]]> { const map = new MapData(await getJSON(`resources/map/${name}.json`)); return [await loadMap(renderer, map), mkCollision(map.collision)]; } @@ -61,7 +61,7 @@ export class GameContext implements CollidableGroup { private constructor( private readonly renderer: Renderer, - private readonly mapView: SpriteView, + private readonly mapView: SpriteView[], private readonly player: EntityContext, private readonly entities: EntityContext[], private readonly collision: Collidable[], @@ -168,7 +168,8 @@ export class GameContext implements CollidableGroup { this.renderer.setCenter(this.player.pos); this.renderer.clear(); - this.mapView.render(); + for (const layer of this.mapView) + layer.render(); for (const r of [...this.entities, this.player]) r.render(time); -- cgit v1.2.3