From 6f4fe47808a15b07bf77f634eebd73313ac5b0cb Mon Sep 17 00:00:00 2001 From: Chasethechicken Date: Tue, 21 Dec 2021 11:28:07 +0100 Subject: [PATCH 1/7] Add missing layer properties Enables map makers to set the alpha, visibility, origin and size of layers. Co-authored-by: jonny --- front/src/Phaser/Game/GameMap.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/front/src/Phaser/Game/GameMap.ts b/front/src/Phaser/Game/GameMap.ts index 6688acb8..20c78347 100644 --- a/front/src/Phaser/Game/GameMap.ts +++ b/front/src/Phaser/Game/GameMap.ts @@ -81,7 +81,13 @@ export class GameMap { let depth = -2; for (const layer of this.flatLayers) { if (layer.type === "tilelayer") { - this.phaserLayers.push(phaserMap.createLayer(layer.name, terrains, 0, 0).setDepth(depth)); + this.phaserLayers.push( + phaserMap + .createLayer(layer.name, terrains, (layer.x || 0) * 32, (layer.y || 0) * 32) + .setDepth(depth)); + .setAlpha(layer.opacity) + .setVisible(layer.visible) + .setSize(layer.width, layer.height) } if (layer.type === "objectgroup" && layer.name === "floorLayer") { depth = DEPTH_OVERLAY_INDEX; From ba7ea1679995edeea69aa164f27ff035aef2095e Mon Sep 17 00:00:00 2001 From: Chasethechicken Date: Tue, 21 Dec 2021 11:47:43 +0100 Subject: [PATCH 2/7] Add test map --- maps/tests/layer-visibility.json | 100 +++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 maps/tests/layer-visibility.json diff --git a/maps/tests/layer-visibility.json b/maps/tests/layer-visibility.json new file mode 100644 index 00000000..02205819 --- /dev/null +++ b/maps/tests/layer-visibility.json @@ -0,0 +1,100 @@ +{ "compressionlevel":-1, + "height":10, + "infinite":false, + "layers":[ + { + "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + "height":10, + "id":1, + "name":"floor", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":10, + "x":0, + "y":0 + }, + { + "data":[34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34], + "height":10, + "id":7, + "name":"invisible", + "opacity":1, + "type":"tilelayer", + "visible":false, + "width":10, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":10, + "id":2, + "name":"start", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":10, + "x":0, + "y":0 + }, + { + "data":[78, 79, 80, 89, 90, 91, 100, 101, 102], + "height":3, + "id":9, + "name":"smaller-offset", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":3, + "x":3, + "y":3 + }, + { + "draworder":"topdown", + "id":3, + "name":"floorLayer", + "objects":[], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + { + "data":[23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23], + "height":10, + "id":8, + "name":"transparent", + "opacity":0.4, + "type":"tilelayer", + "visible":true, + "width":10, + "x":0, + "y":0 + }], + "nextlayerid":10, + "nextobjectid":2, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.7.2", + "tileheight":32, + "tilesets":[ + { + "columns":11, + "firstgid":1, + "image":"tileset1.png", + "imageheight":352, + "imagewidth":352, + "margin":0, + "name":"tileset1", + "spacing":0, + "tilecount":121, + "tileheight":32, + "tilewidth":32 + }], + "tilewidth":32, + "type":"map", + "version":"1.6", + "width":10 +} \ No newline at end of file From ee46111d3f5f0bda6c9d13a39c5c822eac4d74a6 Mon Sep 17 00:00:00 2001 From: Chasethechicken Date: Tue, 21 Dec 2021 22:22:26 +0100 Subject: [PATCH 3/7] Add test instructions Also make the invisible and alpha layers seperate areas, to make success more obvious. --- maps/tests/layer-visibility.json | 80 +++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/maps/tests/layer-visibility.json b/maps/tests/layer-visibility.json index 02205819..cb65cad7 100644 --- a/maps/tests/layer-visibility.json +++ b/maps/tests/layer-visibility.json @@ -1,40 +1,40 @@ { "compressionlevel":-1, - "height":10, + "height":9, "infinite":false, "layers":[ { - "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - "height":10, + "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + "height":9, "id":1, "name":"floor", "opacity":1, "type":"tilelayer", "visible":true, - "width":10, + "width":9, "x":0, "y":0 }, { - "data":[34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34], - "height":10, + "data":[34, 34, 34, 0, 0, 0, 0, 0, 0, 34, 34, 34, 0, 0, 0, 0, 0, 0, 34, 34, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":9, "id":7, "name":"invisible", "opacity":1, "type":"tilelayer", "visible":false, - "width":10, + "width":9, "x":0, "y":0 }, { - "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - "height":10, + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":9, "id":2, "name":"start", "opacity":1, "type":"tilelayer", "visible":true, - "width":10, + "width":9, "x":0, "y":0 }, @@ -54,7 +54,55 @@ "draworder":"topdown", "id":3, "name":"floorLayer", - "objects":[], + "objects":[ + { + "height":113.62434712736, + "id":2, + "name":"", + "rotation":0, + "text": + { + "text":"The striped tiles in the top left corner should be invisible.", + "wrap":true + }, + "type":"", + "visible":true, + "width":108.583142912147, + "x":4.76293503917236, + "y":3.18514798446498 + }, + { + "height":196.249229945092, + "id":3, + "name":"", + "rotation":0, + "text": + { + "text":"The striped tiles in the top right corner should be transparent and appear above the player.", + "wrap":true + }, + "type":"", + "visible":true, + "width":148.867058808759, + "x":137.442726119928, + "y":2.49946430962904 + }, + { + "height":72.9975893933307, + "id":4, + "name":"", + "rotation":0, + "text": + { + "text":"The plant should be here (the center of the map)", + "wrap":true + }, + "type":"", + "visible":true, + "width":151.609793508102, + "x":83.616557645306, + "y":131.922257934914 + }], "opacity":1, "type":"objectgroup", "visible":true, @@ -62,19 +110,19 @@ "y":0 }, { - "data":[23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23], - "height":10, + "data":[0, 0, 0, 0, 0, 0, 23, 23, 23, 0, 0, 0, 0, 0, 0, 23, 23, 23, 0, 0, 0, 0, 0, 0, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":9, "id":8, "name":"transparent", "opacity":0.4, "type":"tilelayer", "visible":true, - "width":10, + "width":9, "x":0, "y":0 }], "nextlayerid":10, - "nextobjectid":2, + "nextobjectid":5, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.7.2", @@ -96,5 +144,5 @@ "tilewidth":32, "type":"map", "version":"1.6", - "width":10 + "width":9 } \ No newline at end of file From 5197428969d0478846a42cf17e89b2e4a93d610e Mon Sep 17 00:00:00 2001 From: Chasethechicken Date: Tue, 21 Dec 2021 22:24:03 +0100 Subject: [PATCH 4/7] Add link to layer visibility test map --- maps/tests/index.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/maps/tests/index.html b/maps/tests/index.html index c920c876..0fb6bd25 100644 --- a/maps/tests/index.html +++ b/maps/tests/index.html @@ -112,6 +112,14 @@ Focusable Zones + + + Success Failure Pending + + + Layer visibility + Layer size and offset + +

Iframe API

From 66efdebc78467304c7557735f10eb1eb85942dee Mon Sep 17 00:00:00 2001 From: Chasethechicken Date: Tue, 21 Dec 2021 23:22:58 +0100 Subject: [PATCH 5/7] Fix test map --- maps/tests/layer-visibility.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maps/tests/layer-visibility.json b/maps/tests/layer-visibility.json index cb65cad7..b06be89b 100644 --- a/maps/tests/layer-visibility.json +++ b/maps/tests/layer-visibility.json @@ -100,8 +100,8 @@ "type":"", "visible":true, "width":151.609793508102, - "x":83.616557645306, - "y":131.922257934914 + "x":78.3025091653274, + "y":173.920383018616 }], "opacity":1, "type":"objectgroup", @@ -110,7 +110,7 @@ "y":0 }, { - "data":[0, 0, 0, 0, 0, 0, 23, 23, 23, 0, 0, 0, 0, 0, 0, 23, 23, 23, 0, 0, 0, 0, 0, 0, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "data":[0, 0, 0, 0, 0, 0, 34, 34, 34, 0, 0, 0, 0, 0, 0, 34, 34, 34, 0, 0, 0, 0, 0, 0, 34, 34, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "height":9, "id":8, "name":"transparent", From 1ea7b45c7efa88ef86ddd5d44b09ca29f61deb2d Mon Sep 17 00:00:00 2001 From: Chasethechicken Date: Tue, 21 Dec 2021 23:26:15 +0100 Subject: [PATCH 6/7] Fix misplaced semicolon --- front/src/Phaser/Game/GameMap.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front/src/Phaser/Game/GameMap.ts b/front/src/Phaser/Game/GameMap.ts index 20c78347..53ac6020 100644 --- a/front/src/Phaser/Game/GameMap.ts +++ b/front/src/Phaser/Game/GameMap.ts @@ -84,10 +84,11 @@ export class GameMap { this.phaserLayers.push( phaserMap .createLayer(layer.name, terrains, (layer.x || 0) * 32, (layer.y || 0) * 32) - .setDepth(depth)); + .setDepth(depth) .setAlpha(layer.opacity) .setVisible(layer.visible) .setSize(layer.width, layer.height) + ); } if (layer.type === "objectgroup" && layer.name === "floorLayer") { depth = DEPTH_OVERLAY_INDEX; From 6cae134c8f9953fbf39d21e8f1b862363219909b Mon Sep 17 00:00:00 2001 From: Chasethechicken Date: Wed, 22 Dec 2021 10:13:26 +0100 Subject: [PATCH 7/7] Fix indentation To make prettier happy --- front/src/Phaser/Game/GameMap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/Phaser/Game/GameMap.ts b/front/src/Phaser/Game/GameMap.ts index 53ac6020..5778c065 100644 --- a/front/src/Phaser/Game/GameMap.ts +++ b/front/src/Phaser/Game/GameMap.ts @@ -88,7 +88,7 @@ export class GameMap { .setAlpha(layer.opacity) .setVisible(layer.visible) .setSize(layer.width, layer.height) - ); + ); } if (layer.type === "objectgroup" && layer.name === "floorLayer") { depth = DEPTH_OVERLAY_INDEX;