tuned a bit dialogs (validate with SHIFT) + start working on NPCs path

This commit is contained in:
Sylvain PILLOT 2023-08-19 11:16:51 +02:00
parent f56b6432f2
commit 196cbb97ae
5 changed files with 104 additions and 53 deletions

View File

@ -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 EGA64)
set(COLORMODE_cg 1b)
fxconv_declare_converters(assets/converters.py)

View File

@ -234,47 +234,76 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
nbExtraData = 0
layer = data["layers"][layer_extradata]
for i in layer["objects"]:
nbExtraData = nbExtraData + 1
x = i["x"] + xmin
y = i["y"] + ymin
nme = i["name"]
tpe = i["type"]
stg = None
quest = 0
choi = None
conc1 = None
conc2 = None
#get the type of the item
tpe = i["type"]
#we check if the type corresponds to a items of type Point in Tiled
if tpe in ( "SGN", "NPC", "INFO" ):
nbExtraData = nbExtraData + 1
x = i["x"] + xmin
y = i["y"] + ymin
nme = i["name"]
dialog = None
quest = 0
choi = None
conc1 = None
conc2 = None
path = 0
path_length = 0
xdata = None
ydata = None
for j in i["properties"]:
#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"])
#we now fill all the properties of this item
for j in i["properties"]:
#property "dialog"
if j["name"]=="dialog": dialog = 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:
#Extra properties for NPCs (path)
if tpe=="NPC":
if j["name"]=="hasPath":
path = j[ "value" ]
if path==1: print( "PNJ has path" )
else: print( "PNJ has no Path" )
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.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 )
else:
print( "UNIDENTIFIED PROPERTY : ", j["name"])
print( "OBJECT X= ", x, " Y= ", y, "STR= ", dialog )
print( " Type= ", tpe, " Name= ", nme )
print( " Q?= ", quest, " Choi= ", choi )
print( " c1= ", conc1, " c2=", conc2)
structData += fxconv.u32( int(x) )
structData += fxconv.u32( int(y) )
structData += fxconv.string( nme )
structData += fxconv.string( tpe )
structData += fxconv.string( dialog )
structData += fxconv.u32( int(quest) )
structData += fxconv.string( choi )
structData += fxconv.string( conc1 )
structData += fxconv.string( conc2 )
structData += fxconv.u32(0)
structData += fxconv.u32(0)
structData += fxconv.u32(0)
structData += fxconv.u32(0)
#else we do nothing (yet)
else:
break
return nbExtraData, structData

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="8" nextobjectid="9">
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="48" height="24" tilewidth="8" tileheight="8" infinite="0" nextlayerid="8" nextobjectid="10">
<editorsettings>
<export target="level0.json" format="json"/>
</editorsettings>
@ -126,7 +126,9 @@
<property name="conclusion1" value="Voici donc pour toi`$life+5``$mana+5``$power+2`"/>
<property name="conclusion2" value="Bon bah casse toi ..."/>
<property name="dialog" value="Salut Hero, je suis le cremier. Veux tu me delester un peu ?"/>
<property name="hasPath" type="int" value="1"/>
<property name="isQuestion" type="int" value="1"/>
<property name="path" type="object" value="9"/>
</properties>
<point/>
</object>
@ -150,5 +152,8 @@
</properties>
<point/>
</object>
<object id="9" name="TRJ1" type="TRJ" x="251.75" y="165.25">
<polyline points="0,0 -72.25,-18.5 -171.75,-19 -172.5,-99.25 -206.25,-122.75 -140.75,-114.75 -175.25,-97.5 -174.5,-33 -148.25,-20.5 -73.25,-20.25 39,-30.25 81.25,-45 79.25,-24.5"/>
</object>
</objectgroup>
</map>

View File

@ -10,6 +10,10 @@
#define BOX_HEIGHT (F_HEIGHT/PXSIZE+8)
#define CHOICE_BOX_HEIGHT 10
#define CHOICE_BOX_PADDING_TOP 3
extern font_t fontRPG;
#define FONT_USED fontRPG
@ -19,6 +23,14 @@ extern font_t fontRPG;
uint32_t *lightVRAMcurrent, *darkVRAMcurrent;
#endif //GRAYMODEOK
/* the color of the text to go to the next dialog phase */
/* it improves readability to have somathing lighter */
#if GRAYMODEOK || (defined(FXCG50) && !defined(COLOR1BIT))
#define NEXT_COLOR C_LIGHT
#else
#define NEXT_COLOR C_BLACK
#endif
void blit()
{
@ -125,15 +137,15 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
if(update_screen) blit();
while(game->frame_duration < line_duration) sleep();
game->frame_duration = 0;
/* Ask the user to press EXE to continue. */
dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
/* Ask the user to press SHIFT to continue. */
dtext(BOX_HEIGHT*PXSIZE, y, NEXT_COLOR, "[SHIFT] : suite...");
}
/* Make a little animation :). */
if(update_screen) blit();
if(l>=max_lines_amount-1){
/* If we drew one entire screen. */
/* Wait that the EXE key is pressed if we should. */
if(wait_continue) while(getkey().key != KEY_EXE) sleep();
/* Wait that the SHIFT key is pressed if we should. */
if(wait_continue) while(getkey_opt(GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA, NULL).key != KEY_SHIFT) sleep();
/* Clear the text area. */
drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-2,
C_WHITE);
@ -153,11 +165,11 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
if(update_screen) blit();
while(game->frame_duration < line_duration) sleep();
game->frame_duration = 0;
/* Ask the user to press EXE to continue. */
dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
/* Update the screen and wait for EXE being pressed, if needed. */
/* Ask the user to press SHIFT to continue. */
dtext(BOX_HEIGHT*PXSIZE, y, NEXT_COLOR, "[SHIFT] : suite...");
/* Update the screen and wait for SHIFT being pressed, if needed. */
if(update_screen) blit();
if(wait_continue) while(getkey().key != KEY_EXE) sleep();
if(wait_continue) while(getkey_opt( GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA, NULL).key != KEY_SHIFT) sleep();
}
if(call_before_end) return_int = call_before_end(game, i);
if(end_anim){
@ -187,8 +199,6 @@ void showtext_dialog(Game *game, bopti_image_t *face, char *text,
true, 0, true);
}
#define CHOICE_BOX_HEIGHT 10
#define CHOICE_BOX_PADDING_TOP 3
/* Some variables and pointers used to get some arguments passed in
* showtext_dialog_ask in _choice_call_before_end. */
@ -253,7 +263,7 @@ int _choice_call_before_end(Game *game, unsigned int org_i) {
C_BLACK, ">");
}
blit();
key = getkey().key;
key = getkey_opt( GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA, NULL).key;
/* If the player pressed the left arrow key and has not already selected
* the first possible choice. */
if(key == KEY_LEFT && selected > 0){
@ -280,9 +290,9 @@ int _choice_call_before_end(Game *game, unsigned int org_i) {
/* Move the selection arrow and update the selected item. */
selected++;
}
/* If the user has not validated his choice by pressing EXE, we loop one
/* If the user has not validated his choice by pressing SHIFT, we loop one
* more time. */
}while(key != KEY_EXE);
}while(key != KEY_SHIFT);
/* Make a little animation because we looove little animations ;) */
for(i=DWIDTH/8+1;i>0;i--){
/* I'm drawing the same box as on the start animation */

View File

@ -60,6 +60,13 @@ typedef struct {
/* Note : it may contain a set of event with a dedicated syntax */
char *conclusion1;
char *conclusion2;
/* data for NPC's trajectories */
uint32_t hasPath;
uint32_t path_length;
uint16_t *xpath;
uint16_t *ypath;
/* ... this can be extended as per needs ... */
} ExtraData;