commit 5d868c6089b7621ac202e4575fbfd111e8b505e1 Author: SlyVTT Date: Wed Jul 5 23:22:15 2023 +0200 Very first commit to prepare the template of the project - Tileset Ok + Importation Map + Basic Rendering of map in grayscale diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..baadade --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Build files +/build-fx +/build-cg +/build-cg-push +/*.g1a +/*.g3a + +# Python bytecode +__pycache__/ + +# Common IDE files +*.sublime-project +*.sublime-workspace +.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..546de15 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,55 @@ +# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the +# toolchain file and module path of the fxSDK + +cmake_minimum_required(VERSION 3.15) +project(MyAddin) + +include(GenerateG1A) +include(Fxconv) +find_package(Gint 2.9 REQUIRED) +find_package(LibProf 2.4 REQUIRED) + +fxconv_declare_converters(assets-fx/converters.py) + +add_custom_command( + COMMENT "Convert Tiled TMX map to usable JSON file" + COMMAND tiled --export-tileset json tilesetnpp.tsx tilesetnpp.json + 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-fx/levels/ + + OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets-fx/levels/level0.json" +# if several levels/maps are created, just copy the previous line and change the .json name with the new level/map + DEPENDS assets-fx/converters.py + assets-fx/levels/tileset.png + assets-fx/levels/tilesetnpp.tsx + assets-fx/levels/level0.tmx +# if several levels/maps are created, just copy the previous line and change the .json name with the new level/map + ) + + +set(SOURCES + src/main.c + src/map.c + # ... +) +# Shared assets, fx-9860G-only assets and fx-CG-50-only assets +set(ASSETS + # ... +) +set(ASSETS_fx + assets-fx/levels/tileset.png + assets-fx/levels/level0.json + # ... +) + +fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA) + +add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}}) +target_compile_options(myaddin PRIVATE -Wall -Wextra -Os) +target_link_options(myaddin PRIVATE -Wl,-Map=Build_Addin.map -Wl,--print-memory-usage) +target_link_libraries(myaddin LibProf::LibProf Gint::Gint) + +if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) + generate_g1a(TARGET myaddin OUTPUT "Prj_PC.g1a" + NAME "Collab RPG" ICON assets-fx/icon.png) +endif() diff --git a/README.md b/README.md new file mode 100644 index 0000000..f29a45d --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Projet Collaboratif Planete Casio + +## Template + +Voici un premier jet de template pour le projet collaboratif de Planete Casio. + +PLus d'infos sur ce projet ici : [Le projet Collaboratif de PC](https://www.planet-casio.com/Fr/forums/topic17343-last-projet-collaboratif-avec-toute-la-commu.html) + +## Dispo / Pas Dispo + +Le template initialise un projet avec moteur de gris pour les calculatrices fx9860G toute version. + +Importation d'un tileset via un convertisseur tiled/fxconv +Importation d'une carte de tiles (map) via un convertisseur +Dessin de la Map en niveau de gris + + +A ce stade, rien de plus : + +Pas de gestion des touches +Pas de personnage +Pas d'interraction + +Bref, c'est juste le minimum pour offrir qq fonctions de base et ne pas partir de zéro. + +## Crédits + +Les tiles sont issues de Game Boy Top-down RPG Fantasy Tileset (FREE) +"Background Assets by Gumpy Function (gumpyfunction.itch.io)" +[Tiles Background Assets by Gumpy Function](https://gumpyfunction.itch.io/game-boy-rpg-fantasy-tileset-free) + +Converties en niveau de gris avec Gimp diff --git a/assets-fx/converters.py b/assets-fx/converters.py new file mode 100644 index 0000000..53bea37 --- /dev/null +++ b/assets-fx/converters.py @@ -0,0 +1,56 @@ +from random import randint +import fxconv +import json +import pathlib +import csv + +def convert(input, output, params, target): + if params["custom-type"] == "map": + convert_map(input, output, params, target) + return 0 + else: + return 1 + +def convert_map(input, output, params, target): + data = json.load(open(input, "r")) + + #find the tileset in use. it's a relative path (like ../tileset.tsx) + nameTileset = data["tilesets"][0]["source"].replace(".tsx","") + print(nameTileset) + #the name of the tileset without the .something + nameTilesetFree = nameTileset.split("/")[-1] + #count the number of "back" (cd ..) to locate the tileset on the computer + nbRetour = nameTileset.count("..")+1 + #create the tileset absolute path + tilesetPath = "/".join(input.split("/")[:-nbRetour]) + "/" + nameTileset + ".json" + + tileset = open(tilesetPath, "r") + data_tileset = json.load(tileset) + tileset_size = data_tileset.get("columns") + tileset.close() + + + #Extract from the json the width, height + w, h = data["width"], data["height"] + + #nbTileLayer is the number of "true" layers (without ObjectsLayer) + nbTilelayer = ["data" in i for i in data["layers"]].count(True) + + structMap = fxconv.Structure() + + structMap += fxconv.u32(w) + fxconv.u32(h) + fxconv.u32(nbTilelayer) + structMap += fxconv.ref(f"img_{nameTilesetFree}") + structMap += fxconv.u32(tileset_size) + + #generate the array of tiles from the layer + for i in range(nbTilelayer): + layer_data = bytes() + layer = data["layers"][i] + for tile in layer["data"]: + layer_data += fxconv.u16(tile-1) + + structMap += fxconv.ptr(layer_data) + + #generate ! + fxconv.elf(structMap, output, "_" + params["name"], **target) + diff --git a/assets-fx/fxconv-metadata.txt b/assets-fx/fxconv-metadata.txt new file mode 100644 index 0000000..d435d5f --- /dev/null +++ b/assets-fx/fxconv-metadata.txt @@ -0,0 +1,3 @@ +example.png: + type: bopti-image + name: img_example diff --git a/assets-fx/icon.png b/assets-fx/icon.png new file mode 100644 index 0000000..7f0162d Binary files /dev/null and b/assets-fx/icon.png differ diff --git a/assets-fx/levels/fxconv-metadata.txt b/assets-fx/levels/fxconv-metadata.txt new file mode 100644 index 0000000..156bf1a --- /dev/null +++ b/assets-fx/levels/fxconv-metadata.txt @@ -0,0 +1,7 @@ +*.json: + custom-type: map + name_regex: (.*)\.json map_\1 + +tileset.png: + type: bopti-image + name: img_tilesetnpp diff --git a/assets-fx/levels/level0.json b/assets-fx/levels/level0.json new file mode 100644 index 0000000..ab940ec --- /dev/null +++ b/assets-fx/levels/level0.json @@ -0,0 +1,44 @@ +{ "compressionlevel":-1, + "height":24, + "infinite":false, + "layers":[ + { + "data":[257, 297, 298, 299, 300, 257, 386, 297, 298, 299, 300, 0, 0, 0, 0, 0, 257, 0, 0, 225, 226, 227, 228, 201, 202, 203, 204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253, 205, 229, 205, 229, 280, 179, 180, 179, 156, 156, 156, 158, 157, 179, 180, 253, 0, 0, 249, 250, 251, 252, 225, 226, 227, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 301, 125, 126, 127, 128, 0, 385, 303, 350, 351, 303, 0, 0, 0, 350, 351, 301, 0, 0, 273, 274, 275, 276, 249, 250, 251, 252, 201, 202, 203, 204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 325, 149, 150, 151, 152, 0, 0, 327, 374, 375, 327, 0, 184, 185, 374, 375, 325, 0, 279, 297, 298, 299, 300, 273, 274, 275, 276, 225, 226, 227, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 257, 0, 0, 385, 0, 0, 385, 0, 265, 266, 0, 0, 208, 209, 352, 353, 257, 0, 302, 0, 130, 129, 166, 297, 298, 299, 300, 249, 250, 251, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 281, 176, 0, 0, 278, 0, 0, 385, 289, 290, 0, 0, 232, 233, 376, 377, 281, 0, 326, 0, 154, 153, 190, 201, 202, 203, 204, 273, 274, 275, 276, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201, 202, 203, 204, 302, 385, 0, 0, 265, 266, 0, 385, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166, 225, 226, 227, 228, 297, 298, 299, 300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 225, 226, 227, 228, 326, 0, 385, 0, 265, 266, 0, 0, 0, 0, 214, 215, 0, 0, 0, 0, 0, 0, 190, 249, 250, 251, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 249, 250, 251, 252, 201, 202, 203, 204, 289, 290, 0, 258, 259, 260, 238, 239, 260, 260, 261, 262, 262, 263, 264, 273, 274, 275, 276, 0, 93, 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 273, 274, 275, 276, 225, 226, 227, 228, 265, 266, 0, 282, 283, 284, 285, 285, 285, 285, 285, 285, 286, 287, 288, 297, 298, 299, 300, 0, 117, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 297, 298, 299, 300, 249, 250, 251, 252, 290, 0, 0, 306, 307, 308, 309, 308, 309, 308, 309, 310, 310, 311, 312, 131, 0, 339, 340, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 203, 204, 386, 273, 274, 275, 276, 0, 0, 0, 330, 331, 332, 333, 332, 333, 332, 333, 334, 334, 335, 336, 132, 0, 363, 364, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 226, 227, 228, 386, 297, 298, 299, 300, 0, 290, 0, 162, 163, 164, 165, 162, 163, 164, 165, 162, 163, 164, 165, 132, 0, 201, 202, 203, 204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 251, 252, 0, 0, 0, 0, 0, 0, 0, 0, 86, 87, 88, 89, 186, 187, 188, 189, 86, 87, 88, 89, 132, 0, 225, 226, 227, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 274, 275, 276, 0, 270, 271, 271, 271, 272, 0, 0, 110, 111, 112, 113, 210, 211, 212, 213, 110, 111, 112, 113, 133, 0, 249, 250, 251, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 298, 299, 300, 0, 294, 1, 1, 1, 296, 0, 0, 136, 137, 0, 0, 234, 290, 265, 237, 0, 0, 339, 340, 0, 0, 273, 274, 275, 276, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 203, 204, 0, 294, 1, 1, 1, 296, 0, 0, 160, 161, 265, 266, 266, 265, 266, 0, 0, 0, 363, 364, 0, 0, 297, 298, 299, 300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 226, 227, 228, 0, 318, 319, 319, 319, 320, 0, 0, 0, 0, 289, 290, 265, 266, 290, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 251, 252, 0, 0, 0, 0, 0, 0, 385, 386, 0, 0, 265, 265, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 274, 275, 276, 201, 202, 203, 204, 257, 0, 0, 0, 257, 0, 265, 265, 0, 257, 0, 0, 0, 257, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 298, 299, 300, 225, 226, 227, 228, 253, 205, 229, 205, 253, 0, 290, 265, 0, 253, 205, 229, 205, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 386, 249, 250, 251, 252, 345, 346, 347, 348, 277, 0, 265, 266, 0, 301, 386, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 203, 204, 273, 274, 275, 276, 369, 370, 371, 372, 301, 0, 289, 290, 0, 325, 387, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 226, 227, 228, 297, 298, 299, 300, 393, 394, 395, 396, 325, 0, 265, 266, 0, 301, 386, 0, 0, 0, 0, 257, 0, 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":24, + "id":1, + "name":"Background", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":48, + "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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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":24, + "id":2, + "name":"Foreground", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":48, + "x":0, + "y":0 + }], + "nextlayerid":3, + "nextobjectid":1, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.8.0", + "tileheight":8, + "tilesets":[ + { + "firstgid":1, + "source":"tilesetnpp.tsx" + }], + "tilewidth":8, + "type":"map", + "version":"1.8", + "width":48 +} \ No newline at end of file diff --git a/assets-fx/levels/level0.tmx b/assets-fx/levels/level0.tmx new file mode 100644 index 0000000..e559458 --- /dev/null +++ b/assets-fx/levels/level0.tmx @@ -0,0 +1,60 @@ + + + + + +257,297,298,299,300,257,386,297,298,299,300,0,0,0,0,0,257,0,0,225,226,227,228,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +253,205,229,205,229,280,179,180,179,156,156,156,158,157,179,180,253,0,0,249,250,251,252,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +301,125,126,127,128,0,385,303,350,351,303,0,0,0,350,351,301,0,0,273,274,275,276,249,250,251,252,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +325,149,150,151,152,0,0,327,374,375,327,0,184,185,374,375,325,0,279,297,298,299,300,273,274,275,276,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +257,0,0,385,0,0,385,0,265,266,0,0,208,209,352,353,257,0,302,0,130,129,166,297,298,299,300,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +281,176,0,0,278,0,0,385,289,290,0,0,232,233,376,377,281,0,326,0,154,153,190,201,202,203,204,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +201,202,203,204,302,385,0,0,265,266,0,385,0,0,0,0,0,0,0,0,0,0,166,225,226,227,228,297,298,299,300,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +225,226,227,228,326,0,385,0,265,266,0,0,0,0,214,215,0,0,0,0,0,0,190,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +249,250,251,252,201,202,203,204,289,290,0,258,259,260,238,239,260,260,261,262,262,263,264,273,274,275,276,0,93,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +273,274,275,276,225,226,227,228,265,266,0,282,283,284,285,285,285,285,285,285,286,287,288,297,298,299,300,0,117,118,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +297,298,299,300,249,250,251,252,290,0,0,306,307,308,309,308,309,308,309,310,310,311,312,131,0,339,340,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +202,203,204,386,273,274,275,276,0,0,0,330,331,332,333,332,333,332,333,334,334,335,336,132,0,363,364,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +226,227,228,386,297,298,299,300,0,290,0,162,163,164,165,162,163,164,165,162,163,164,165,132,0,201,202,203,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +250,251,252,0,0,0,0,0,0,0,0,86,87,88,89,186,187,188,189,86,87,88,89,132,0,225,226,227,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +274,275,276,0,270,271,271,271,272,0,0,110,111,112,113,210,211,212,213,110,111,112,113,133,0,249,250,251,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +298,299,300,0,294,1,1,1,296,0,0,136,137,0,0,234,290,265,237,0,0,339,340,0,0,273,274,275,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +202,203,204,0,294,1,1,1,296,0,0,160,161,265,266,266,265,266,0,0,0,363,364,0,0,297,298,299,300,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +226,227,228,0,318,319,319,319,320,0,0,0,0,289,290,265,266,290,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +250,251,252,0,0,0,0,0,0,385,386,0,0,265,265,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +274,275,276,201,202,203,204,257,0,0,0,257,0,265,265,0,257,0,0,0,257,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +298,299,300,225,226,227,228,253,205,229,205,253,0,290,265,0,253,205,229,205,253,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,386,249,250,251,252,345,346,347,348,277,0,265,266,0,301,386,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +202,203,204,273,274,275,276,369,370,371,372,301,0,289,290,0,325,387,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +226,227,228,297,298,299,300,393,394,395,396,325,0,265,266,0,301,386,0,0,0,0,257,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + diff --git a/assets-fx/levels/tileset.png b/assets-fx/levels/tileset.png new file mode 100644 index 0000000..2c2ad04 Binary files /dev/null and b/assets-fx/levels/tileset.png differ diff --git a/assets-fx/levels/tilesetnpp.json b/assets-fx/levels/tilesetnpp.json new file mode 100644 index 0000000..281733b --- /dev/null +++ b/assets-fx/levels/tilesetnpp.json @@ -0,0 +1,14 @@ +{ "columns":24, + "image":"tileset.png", + "imageheight":136, + "imagewidth":192, + "margin":0, + "name":"tileset", + "spacing":0, + "tilecount":408, + "tiledversion":"1.8.0", + "tileheight":8, + "tilewidth":8, + "type":"tileset", + "version":"1.8" +} \ No newline at end of file diff --git a/assets-fx/levels/tilesetnpp.tsx b/assets-fx/levels/tilesetnpp.tsx new file mode 100644 index 0000000..355b9f0 --- /dev/null +++ b/assets-fx/levels/tilesetnpp.tsx @@ -0,0 +1,4 @@ + + + + diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..9c286a9 --- /dev/null +++ b/src/main.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include "map.h" + + + + + + + + +int main(void) +{ + dclear(C_WHITE); + + dgray( DGRAY_ON ); + + RenderMap(); + + dupdate(); + + getkey(); + return 1; +} diff --git a/src/map.c b/src/map.c new file mode 100644 index 0000000..8b9ee72 --- /dev/null +++ b/src/map.c @@ -0,0 +1,27 @@ +#include "map.h" +#include + +extern struct Map map_level0; + +struct Map *map_level = &map_level0; + +void RenderMap(void) +{ + for (int u = 0; u < map_level->nblayers; u++) + { + for (int i = 0; i < map_level->w; i++) + { + for (int j = 0; j < map_level->h; j++) + { + uint16_t index = j * map_level->w + i; + int16_t currentTile = map_level->layers[u][index]; + if (currentTile != -1) + { + uint16_t xtile = (currentTile % map_level->tileset_size) * 8; + uint16_t ytile = (currentTile / map_level->tileset_size) * 8; + dsubimage(i * 8, j * 8, map_level->tileset, xtile, ytile, 8, 8, DIMAGE_NONE ); + } + } + } + } +} diff --git a/src/map.h b/src/map.h new file mode 100644 index 0000000..0667bc2 --- /dev/null +++ b/src/map.h @@ -0,0 +1,25 @@ +#ifndef MAP_H +#define MAP_H + + +#include + + +void RenderMap(void); + + +struct Map { + /*width, height and the number of layer of the map*/ + int w, h, nblayers; + + /*the tileset to use*/ + bopti_image_t *tileset; + int tileset_size; + + /*list of all the tiles*/ + short *layers[]; +}; + + + +#endif