diff --git a/assets-cg/font.png b/assets-cg/font.png index 73c7244..d1dd75a 100644 Binary files a/assets-cg/font.png and b/assets-cg/font.png differ diff --git a/assets/converters.py b/assets/converters.py index cd3b933..b073ed6 100644 --- a/assets/converters.py +++ b/assets/converters.py @@ -123,10 +123,10 @@ def get_tile_map_data(input, output, params, target, xmin, ymin, xmax, ymax): #create the structure of the map structMap = fxconv.Structure() - structMap += fxconv.u16(w) + fxconv.u16(h) + fxconv.u16(nbTilelayer) - structMap += fxconv.u16(tileset_size) + structMap += fxconv.u32(w) + fxconv.u32(h) + fxconv.u32(nbTilelayer) + structMap += fxconv.u32(tileset_size) - structMap += fxconv.u16(xmin) + fxconv.u16(ymin) + fxconv.u16(xmax) + fxconv.u16(ymax) + structMap += fxconv.u32(xmin) + fxconv.u32(ymin) + fxconv.u32(xmax) + fxconv.u32(ymax) structMap += fxconv.ref(f"img_{nameTilesetFree}") @@ -239,15 +239,42 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax): y = i["y"] + ymin nme = i["name"] tpe = i["type"] + + stg = None + quest = 0 + choi = None + conc1 = None + conc2 = None + + for j in i["properties"]: - stg = j[ "value" ] - print( "OBJECT X= ", x, " Y= ", y, "STR= ", stg ) - print( " Type= ", tpe, " Name= ", nme ) + #property "dialog" + if j["name"]=="dialog": stg = j[ "value" ] + #property "isQuestion" + elif j["name"]=="isQuestion": quest = j[ "value" ] + #property "choices" + elif j["name"]=="choices": + choi = j[ "value" ] + choi = choi.replace( '$', chr(0) ) + #property "conclusion1" + elif j["name"]=="conclusion1": conc1 = j[ "value" ] + #property "conclusion2" + elif j["name"]=="conclusion2": conc2 = j[ "value" ] + else: print( "UNIDENTIFIED PROPERTY : ", j["name"]) + + print( "OBJECT X= ", x, " Y= ", y, "STR= ", stg ) + print( " Type= ", tpe, " Name= ", nme ) + print( " Q?= ", quest, " Choi= ", choi ) + print( " c1= ", conc1, " c2=", conc2) - structData += fxconv.u16( int(x) ) - structData += fxconv.u16( int(y) ) + structData += fxconv.u32( int(x) ) + structData += fxconv.u32( int(y) ) structData += fxconv.string( nme ) structData += fxconv.string( tpe ) structData += fxconv.string( stg ) + structData += fxconv.u32( int(quest) ) + structData += fxconv.string( choi ) + structData += fxconv.string( conc1 ) + structData += fxconv.string( conc2 ) return nbExtraData, structData diff --git a/assets/level0.tmx b/assets/level0.tmx index e6fd8eb..efa3940 100644 --- a/assets/level0.tmx +++ b/assets/level0.tmx @@ -92,37 +92,61 @@ - + + + + + + + + + - + - + + + + + - + + + + + + + + + + + + + diff --git a/assets/level1.tmx b/assets/level1.tmx index 20e3824..5f6f37a 100644 --- a/assets/level1.tmx +++ b/assets/level1.tmx @@ -89,7 +89,11 @@ + + + + diff --git a/assets/level2.tmx b/assets/level2.tmx index 6d1fb52..6eede1e 100644 --- a/assets/level2.tmx +++ b/assets/level2.tmx @@ -89,19 +89,31 @@ + + + + + + + + + + + + diff --git a/assets/level3.tmx b/assets/level3.tmx index d756a70..2ac318b 100644 --- a/assets/level3.tmx +++ b/assets/level3.tmx @@ -89,31 +89,51 @@ + + + + + + + + - + + + + + + + + + + + + + diff --git a/src/game.h b/src/game.h index d6237e6..adb7cdc 100644 --- a/src/game.h +++ b/src/game.h @@ -44,31 +44,39 @@ typedef struct { typedef struct { /* position of the item */ - uint16_t x; - uint16_t y; + uint32_t x; + uint32_t y; /* its name */ char *name; /* its class (NPC, SGN, INFO, ... )*/ char *type; /* data to be shown in the dialog*/ char *dialog; + /* is it a question or a simple dialog ? */ + uint32_t isQuestion; + /* if it is a question, then the choices for answering */ + char *choices; + /* the conclusion of the dialog for answer 1 and 2 respectively */ + /* Note : it may contain a set of event with a dedicated syntax */ + char *conclusion1; + char *conclusion2; /* ... this can be extended as per needs ... */ } ExtraData; typedef struct { /* width, height and the number of layer of the map */ - uint16_t w; - uint16_t h; - uint16_t nblayers; - uint16_t tileset_size; + uint32_t w; + uint32_t h; + uint32_t nblayers; + uint32_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; - uint16_t ymax; + uint32_t xmin; + uint32_t ymin; + uint32_t xmax; + uint32_t ymax; /* the tileset to use */ bopti_image_t *tileset; diff --git a/src/main.c b/src/main.c index f0a98dc..5d1cc83 100644 --- a/src/main.c +++ b/src/main.c @@ -108,11 +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 */ diff --git a/src/player.c b/src/player.c index ed7067f..08f1716 100644 --- a/src/player.c +++ b/src/player.c @@ -1,5 +1,6 @@ #include "player.h" #include "dialogs.h" +#include "game.h" #include "map.h" #include "config.h" #include @@ -90,21 +91,40 @@ void player_action(Game *game) { /* we indicate that the player is occupied */ game->player.isDoingAction = true; + ExtraData *currentData = &game->map_level->extradata[game->player.whichAction]; + /* we collect the information */ - char *text = game->map_level->extradata[game->player.whichAction].dialog; + char *text = currentData->dialog; /* we use the correct image as per the class of the item */ bopti_image_t *face; - if (strcmp("INFO", game->map_level->extradata[game->player.whichAction].type)==0) + if (strcmp("INFO", currentData->type)==0) face = &INFO_Icon_img; - else if (strcmp("NPC", game->map_level->extradata[game->player.whichAction].type)==0) + else if (strcmp("NPC", currentData->type)==0) face = &NPC_Icon_img; - else if (strcmp("SGN", game->map_level->extradata[game->player.whichAction].type)==0) + else if (strcmp("SGN", currentData->type)==0) face = &SGN_Icon_img; else face = &demo_player_img; - /* we treat the action - i.e. we show a dialog */ - showtext_dialog( game, face, text, true, true ); - + /* we treat the action - i.e. we show a dialog */ + if (currentData->isQuestion==1) /* we have to manage a question */ + { + char *choices = currentData->choices; + char *conclusion1 = currentData->conclusion1; + char *conclusion2 = currentData->conclusion2; + + int answer = showtext_dialog_ask( game, face, text, true, true, choices, 2, 0 ); + + /* TO DO we need to split the strings conclusion1 and conclusion2 */ + /* to extract the "gift" part */ + + if (answer==0) showtext_dialog( game, face, conclusion1, true, true ); + else showtext_dialog( game, face, conclusion2, true, true ); + } + else + { + showtext_dialog( game, face, text, true, true ); + } + /* when done we release the occupied status of the player */ game->player.isDoingAction = false; }