From: Elias Fleckenstein Date: Thu, 1 Jul 2021 13:56:37 +0000 (+0200) Subject: Implement per-map sky X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=e50ba3e9d31bff8b2155400ff20968cede5de38c;p=dragonblocks.git Implement per-map sky --- diff --git a/engine/map.js b/engine/map.js index 7dff2bc..48c1679 100644 --- a/engine/map.js +++ b/engine/map.js @@ -37,21 +37,21 @@ dragonblocks.Map = class serialize() { return { - data: this.data, width: this.width, height: this.height, - structures: this.structures, + sky: this.sky, + data: this.data, entities: dblib.removeTmp(this.entities), + structures: this.structures, }; } deserialize(data) { - this.data = []; - this.width = data.width; this.height = data.height; - + this.sky = data.sky; + this.data = []; this.entities = []; this.structures = data.structures || {}; @@ -139,6 +139,13 @@ dragonblocks.Map = class return new dragonblocks.SpawnedEntity(def, this, x, y); } + setSky(sky) + { + this.sky = sky; + + if (this.active) + dragonblocks.mapMgr.setSky(this.sky); + } }; dragonblocks.mapMgr = new dragonblocks.ContentMgr(dragonblocks.Map); diff --git a/engine/map_display.js b/engine/map_display.js index 5e72d9e..2c546f2 100644 --- a/engine/map_display.js +++ b/engine/map_display.js @@ -88,6 +88,8 @@ dragonblocks.MapDisplay = class this.map = map; this.map.setActive(); + this.setSky(this.map.sky); + this.autoScroll() || this.update(); } @@ -190,9 +192,8 @@ dragonblocks.registerOnQuit(_ => { }); dragonblocks.registerOnStarted(_ => { - dragonblocks.mapDisplay.setSky("skyblue"); - dragonblocks.mapDisplay.setMap(dragonblocks.player.map); dragonblocks.mapDisplay.setAnchor(dragonblocks.player); + dragonblocks.mapDisplay.setMap(dragonblocks.player.map); dragonblocks.mapDisplay.setActive(); }); diff --git a/settings.json b/settings.json index 034ef4b..d14f848 100644 --- a/settings.json +++ b/settings.json @@ -18,7 +18,8 @@ }, "map": { "width": 250, - "height": 100 + "height": 100, + "sky": "skyblue" }, "mapDisplay": { "scale": 50