diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a9e915..df83849 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ find_package(LibProf 2.4 REQUIRED) #set the color mode either to 1b or 2b set(COLORMODE_fx 2b) #set the color mode either to 1b, 2b or EGA64 -set(COLORMODE_cg 1b) +set(COLORMODE_cg 2b) fxconv_declare_converters(assets/converters.py) diff --git a/assets/converters.py b/assets/converters.py index a7ab5ae..cd3b933 100644 --- a/assets/converters.py +++ b/assets/converters.py @@ -27,7 +27,8 @@ def convert_world(input, output, params, target): print( "So let's go ... ") structWorld = fxconv.Structure() - + #structExtra = fxconv.Structure() + for i in range(nbMaps): nameMap = data["maps"][i]["fileName"].replace(".tmx","") nameMapFree = nameMap.split("/")[-1] @@ -61,47 +62,22 @@ def convert_world(input, output, params, target): print( "Map = ", map ) structWorld += fxconv.ptr( map ) + #ext = get_extra_map_data( mapPath, output, params, target, xmin, ymin, xmax, ymax ) + #print( "Data = ", ext ) + #if (ext!=fxconv.u32(0)): structExtra += fxconv.ptr( ext ) + structWorld += fxconv.u32(0) - #generate ! - #the map data - fxconv.elf(structWorld, output, "_" + params["name"], **target) - - -""" - structExtra = fxconv.Structure() - - for i in range(nbMaps): - - nameMap = data["maps"][i]["fileName"].replace(".tmx","") - nameMapFree = nameMap.split("/")[-1] - #count the number of "back" (cd ..) to locate the map on the computer - nbRetour = nameMap.count("..")+1 - #create the map absolute path - - mapPath = "/".join(input.split("/")[:-nbRetour]) + "/" + nameMap + ".json" - print("Map ", i , " name : ", mapPath ) - - xmin = data["maps"][i]["x"] - print( "xmin = ", xmin ) - - ymin = data["maps"][i]["y"] - print( "ymin = ", ymin ) - - xmax = data["maps"][i]["x"] + data["maps"][i]["width"] - print( "xmax = ", xmax ) - - ymax = data["maps"][i]["y"] + data["maps"][i]["height"] - print( "ymax = ", ymax ) - - ext = get_extra_map_data( mapPath, output, params, target, xmin, ymin, xmax, ymax ) - print( "Data = ", ext ) - if (ext!=fxconv.u32(0)): structExtra += fxconv.ptr( ext ) - - structExtra += fxconv.u32(0) + #structExtra += fxconv.u32(0) + """ #and all the extra data (PNJ, SGN, ...) - fxconv.elf(structExtra, output, "_" + params["name"]+"Extra", **target) -""" + fxconv.elf_multi( + [("_" + params["varMapData"], structWorld), + ("_" + params["varExtraData"], structExtra)], + output, **target) + """ + #generate ! + fxconv.elf(structWorld, output, "_" + params["name"], **target) def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax): @@ -174,6 +150,18 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax): structMap += fxconv.ptr(walk_data) + nbextra = 0 + extradata = fxconv.Structure() + + nbextra, extradata = get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax) + + if (nbextra==0): + structMap += fxconv.u32( 0 ) + structMap += fxconv.u32( 0 ) + else: + structMap += fxconv.u32( int(nbextra) ) + structMap += fxconv.ptr( extradata ) + #extraction of the data contained in the layer "Background" and "Foreground" of the map @@ -212,8 +200,6 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax): layer_data += fxconv.u16(tile-1) structMap += fxconv.ptr(layer_data) - #generate ! - #fxconv.elf(structMap, output, "_" + params["name"], **target) return structMap @@ -239,20 +225,29 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax): break elif i==nblayer: print( "ERROR : No ExtraData layer data !!!" ) - return fxconv.u32(0) + return 0, fxconv.u32(0) #create the structure of the map structData = fxconv.Structure() + + nbExtraData = 0 layer = data["layers"][layer_extradata] for i in layer["objects"]: + nbExtraData = nbExtraData + 1 x = i["x"] + xmin y = i["y"] + ymin - st = i[ "type" ] - print( "OBJECT X= ", x, " Y= ", y, "STR= ", st ) - structData += fxconv.u16( x ) - structData += fxconv.u16( y ) - structData += fxconv.string( st ) + nme = i["name"] + tpe = i["type"] + for j in i["properties"]: + stg = j[ "value" ] + print( "OBJECT X= ", x, " Y= ", y, "STR= ", stg ) + print( " Type= ", tpe, " Name= ", nme ) + + structData += fxconv.u16( int(x) ) + structData += fxconv.u16( int(y) ) + structData += fxconv.string( nme ) + structData += fxconv.string( tpe ) + structData += fxconv.string( stg ) - - return structData + return nbExtraData, structData diff --git a/assets/fxconv-metadata.txt b/assets/fxconv-metadata.txt index 0176752..d38d6f6 100644 --- a/assets/fxconv-metadata.txt +++ b/assets/fxconv-metadata.txt @@ -3,7 +3,9 @@ # name_regex: (.*)\.json map_\1 -*.world: +WorldRPG.world: custom-type: world -# extra: extraRPG + #name: xxx #unused but mandatory (Do not touch) + #varMapData: worldRPG + #varExtraData: extraRPG name: worldRPG diff --git a/clean b/clean index 3e99971..db7550f 100755 --- a/clean +++ b/clean @@ -3,6 +3,7 @@ rm -f *.json rm -r __pycache__ cd .. rm -r build-cg +rm -r build-cg-push rm -r build-fx rm *.g1a rm *.g3a diff --git a/src/game.c b/src/game.c index 64d3765..284ce7c 100644 --- a/src/game.c +++ b/src/game.c @@ -7,8 +7,12 @@ #include #include + + void game_logic(Game *game) { - // to be done + + + } void draw(Game *game) { diff --git a/src/game.h b/src/game.h index 5dc51c5..af724b5 100644 --- a/src/game.h +++ b/src/game.h @@ -2,6 +2,7 @@ #define GAME_H #include +#include @@ -33,17 +34,23 @@ typedef struct { typedef struct { - uint16_t x, y; - char type[3]; + uint16_t x; + uint16_t y; + char *name; + char *type; + char *dialog; } ExtraData; typedef struct { /* width, height and the number of layer of the map */ - uint16_t w, h; + uint16_t w; + uint16_t h; uint16_t nblayers; uint16_t tileset_size; + /* world coordinates of the upper left and bootom right*/ + /* corners of the current map to be multiplied in game by PXSIZE */ uint16_t xmin; uint16_t ymin; uint16_t xmax; @@ -57,8 +64,13 @@ typedef struct { uint8_t *walkable; + uint32_t nbextradata; + ExtraData *extradata; + /* list of all the tiles */ uint16_t *layers[]; + + } Map; @@ -80,8 +92,9 @@ typedef struct { long int frame_duration; /* variables used for debuging */ - bool debug_player; bool debug_map; + bool debug_player; + bool debug_extra; } Game; /* (Mibi88) TODO: Describe what this function is doing. */ diff --git a/src/main.c b/src/main.c index eef0fec..07d98d8 100644 --- a/src/main.c +++ b/src/main.c @@ -26,8 +26,8 @@ extern bopti_image_t player_face_img; -extern Map *worldRPG[]; +extern Map *worldRPG[]; /* Game data (defined in "game.h")*/ Game game = { @@ -36,7 +36,7 @@ Game game = { false, false, false, 0 /* debug variables*/ - , false, false + , false, false, true }; /* screen capture management code */ @@ -108,13 +108,13 @@ int main(void) { dgray(DGRAY_ON); #endif - +/* showtext_dialog(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, true); int in = showtext_dialog_ask(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, false, "Lorem\0Ipsum\0Dolor", 3, 0); if(in==2) showtext_dialog(&game, &player_face_img, "You choosed Dolor", false, true); else if(in==1) showtext_dialog(&game, &player_face_img, "You choosed Ipsum", false, true); else showtext_dialog(&game, &player_face_img, "You choosed Lorem", false, true); - +*/ do{ /* clear screen */ @@ -139,6 +139,13 @@ int main(void) { drect( 5, 55,390, 75, C_WHITE ); dprint( 10, 60, C_BLUE, "X= %d - Y= %d / Wx= %d - Wy= %d", game.player.x, game.player.y, game.player.wx, game.player.wy ); } + if (game.debug_extra) + { + dfont( NULL ); + //drect( 155, 80, 390, 150, C_WHITE ); + for (int i=0; inbextradata; i++ ) + dprint( 10, 90+i*15, C_RED, "X= %d - Y= %d - T: %s", game.map_level->extradata[i].x, game.map_level->extradata[i].y, game.map_level->extradata[i].dialog ); + } #endif /* start the logic of the game */ diff --git a/src/map.c b/src/map.c index 94b43ff..5670485 100644 --- a/src/map.c +++ b/src/map.c @@ -5,7 +5,7 @@ #include extern Map *worldRPG[]; -//extern ExtraData *extraRPG[]; +extern ExtraData *extraRPG[]; void render_map(Game *game) {