diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65a5139..87b0203 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,7 @@ add_custom_command(
COMMAND find | grep .*.tmx | sed 's/.tmx//g' | xargs -l bash -c 'tiled --export-map json $$0.tmx $$0.json'
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets-cg/maps/
DEPENDS assets-cg/maps/testCarte.tmx
+ assets-cg/maps/1.tmx
assets-cg/tileset.png
assets-cg/maps/tileset.tsx
assets-cg/converters.py
@@ -44,6 +45,7 @@ set(SOURCES
set(ASSETS_cg
assets-cg/tileset.png
assets-cg/maps/testCarte.json
+ assets-cg/maps/1.json
assets-cg/maps/inside/1.json
assets-cg/maps/inside/2.json
assets-cg/maps/inside/3.json
diff --git a/assets-cg/converters.py b/assets-cg/converters.py
index 0a785d3..efbf037 100644
--- a/assets-cg/converters.py
+++ b/assets-cg/converters.py
@@ -15,8 +15,10 @@ def convert_map(input, output, params, target):
TILE_DOOR_IN = 2
TILE_DOOR_OUT = 3
TILE_TALKABLE = 4
+ TILE_TELEPORTER = 5
DIALOG_LAYOUT = "dialog"
+ TELEPORTER_LAYOUT = "teleporter"
data = json.load(open(input, "r"))
@@ -51,6 +53,8 @@ def convert_map(input, output, params, target):
value = TILE_TALKABLE
elif type == "bridge":
value = TILE_BRIDGE
+ elif type == "teleporter":
+ value = TILE_TELEPORTER
else:
value = TILE_AIR
@@ -64,19 +68,25 @@ def convert_map(input, output, params, target):
objectLayers = data["layers"][nbTilelayer:len(data["layers"])]
nbDialog = 0
+ nbTelep = 0
structMap = fxconv.Structure()
dialogs = fxconv.Structure()
+ teleporter = fxconv.Structure()
for layer in objectLayers:
if layer.get("name") == DIALOG_LAYOUT:
nbDialog = len(layer["objects"])
dialogs = parseDialog(layer)
+ elif layer.get("name") == TELEPORTER_LAYOUT:
+ nbTelep = len(layer["objects"])
+ teleporter = parseTeleporter(layer)
else:
print("UNKNOWN LAYOUT FOUND : " + layer.get("name"))
- structMap += fxconv.u32(w) + fxconv.u32(h) + fxconv.u32(nbTilelayer) + fxconv.u32(nbDialog)
+ structMap += fxconv.u32(w) + fxconv.u32(h) + fxconv.u32(nbTilelayer) + fxconv.u32(nbDialog) + fxconv.u32(nbTelep)
structMap += fxconv.ref(f"img_{nameTilesetFree}")
structMap += fxconv.ptr(dialogs)
+ structMap += fxconv.ptr(teleporter)
#generation of the collision map (take the maximum of the layer except for bridges)
#bridges are always walkable
@@ -126,4 +136,23 @@ def parseDialog(layer):
except KeyError:
dialogs += fxconv.string("default name")
dialogs += fxconv.string("default text")
- return dialogs
\ No newline at end of file
+ return dialogs
+
+def parseTeleporter(layer):
+ teleporter = fxconv.Structure()
+ for i in layer["objects"]:
+ teleporter += fxconv.u32(int(i["x"]/i["width"]))
+ #Tiled seem to start at the bottom y of the object
+ teleporter += fxconv.u32(int(i["y"]/i["width"])-1)
+
+ try:
+ if len(i["properties"]) < 2:
+ raise Exception("parseTeleporter() : Un téléporteur est mal configuré")
+ if len(i["properties"]) == 2:
+ print("parseTeleporter() : passage automatique idMap = -1 sur téléporteur x = " + str(i["properties"][0]["value"]) + ", y = " + str(i["properties"][1]["value"]))
+ teleporter += fxconv.u32(-1);
+ for j in i["properties"]:
+ teleporter += fxconv.u32(j["value"])
+ except KeyError :
+ raise Exception("parseTeleporter() : Un téléporteur est mal configuré")
+ return teleporter
\ No newline at end of file
diff --git a/assets-cg/maps/1.tmx b/assets-cg/maps/1.tmx
new file mode 100644
index 0000000..a61403b
--- /dev/null
+++ b/assets-cg/maps/1.tmx
@@ -0,0 +1,52 @@
+
+
diff --git a/assets-cg/maps/fxconv-metadata.txt b/assets-cg/maps/fxconv-metadata.txt
index f4c8d95..8b869dc 100644
--- a/assets-cg/maps/fxconv-metadata.txt
+++ b/assets-cg/maps/fxconv-metadata.txt
@@ -1,3 +1,6 @@
testCarte.json:
custom-type: map
name: map_1
+1.json:
+ custom-type: map
+ name: map_2
diff --git a/assets-cg/maps/inside/1.tmx b/assets-cg/maps/inside/1.tmx
index 034794d..3eb9d36 100644
--- a/assets-cg/maps/inside/1.tmx
+++ b/assets-cg/maps/inside/1.tmx
@@ -1,5 +1,5 @@
-