Merge pull request 'MaJ vers dev' (#4) from Slyvtt/Collab_RPG:dev into master
Reviewed-on: https://gitea.planet-casio.com/Fcalva/Collab_RPG_Fcalva/pulls/4
|
@ -25,6 +25,7 @@ set(SOURCES
|
|||
src/memory.c
|
||||
src/game.c
|
||||
src/dialogs.c
|
||||
src/npc.c
|
||||
# ...
|
||||
)
|
||||
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
|
||||
|
|
BIN
assets-cg/NPC_Icon_2.png
Normal file
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 875 B After Width: | Height: | Size: 19 KiB |
|
@ -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}")
|
||||
|
||||
|
@ -230,24 +230,105 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
|||
#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
|
||||
nme = i["name"]
|
||||
|
||||
#get the type of the item
|
||||
tpe = i["type"]
|
||||
for j in i["properties"]:
|
||||
stg = j[ "value" ]
|
||||
print( "OBJECT X= ", x, " Y= ", y, "STR= ", stg )
|
||||
|
||||
#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
|
||||
|
||||
#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":
|
||||
pathID = None
|
||||
path = j[ "value" ]
|
||||
if path==1:
|
||||
print( "PNJ has path - NOW LOOKING FOR RELEVANT DATA" )
|
||||
|
||||
# we start looking for path data with first the ID of the path Object
|
||||
for u in i["properties"]:
|
||||
if u["name"]=="path":
|
||||
pathID = u[ "value" ]
|
||||
print( "path ID is identified : ID= ", pathID )
|
||||
|
||||
for v in layer["objects"]:
|
||||
if v[ "id" ] == pathID:
|
||||
print( "path data found : " )
|
||||
xdata = bytes()
|
||||
ydata = bytes()
|
||||
for w in v[ "polyline" ]:
|
||||
path_length = path_length + 1
|
||||
print( "X= ", w[ "x" ], " Y= ", w[ "y" ] )
|
||||
xdata += fxconv.u16( int( w[ "x" ] ) )
|
||||
ydata += fxconv.u16( int( w[ "y" ] ) )
|
||||
|
||||
else:
|
||||
print( "PNJ has no Path" )
|
||||
|
||||
else:
|
||||
print( "UNIDENTIFIED PROPERTY : ", j["name"])
|
||||
|
||||
print( "OBJECT X= ", x, " Y= ", y, "STR= ", dialog )
|
||||
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 )
|
||||
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 )
|
||||
if path==0:
|
||||
structData += fxconv.u32(0)
|
||||
structData += fxconv.u32(0)
|
||||
structData += fxconv.u32(0)
|
||||
structData += fxconv.u32(0)
|
||||
else:
|
||||
structData += fxconv.u32(path)
|
||||
structData += fxconv.u32(path_length)
|
||||
structData += fxconv.ptr( xdata )
|
||||
structData += fxconv.ptr( ydata )
|
||||
|
||||
#else we do nothing (yet)
|
||||
else:
|
||||
break
|
||||
|
||||
return nbExtraData, structData
|
||||
|
|
|
@ -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="11">
|
||||
<editorsettings>
|
||||
<export target="level0.json" format="json"/>
|
||||
</editorsettings>
|
||||
|
@ -92,39 +92,80 @@
|
|||
<objectgroup id="4" name="ExtraData">
|
||||
<object id="1" name="INFO3" type="INFO" x="232" y="79.75">
|
||||
<properties>
|
||||
<property name="dialog" value="Etrange ce coffre ouvert ..."/>
|
||||
<property name="choices" value="Oui$Non"/>
|
||||
<property name="conclusion1" value="Trop cool, du stuff `$life+5``$mana+5``$power+2`"/>
|
||||
<property name="conclusion2" value="Je ferai mieux de partir loin ..."/>
|
||||
<property name="dialog" value="Etrange ce coffre ouvert ... Fouiller dedans ?"/>
|
||||
<property name="isQuestion" type="int" value="1"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="8" name="INFO2" type="INFO" x="119.75" y="47.25">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Et sa tombe est en train d'etre creusee ...^"/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="7" name="INFO2" type="INFO" x="52" y="44">
|
||||
<object id="7" name="INFO1" type="INFO" x="52" y="44">
|
||||
<properties>
|
||||
<property name="dialog" value="Quelqu'un est mort ici ..."/>
|
||||
<property name="choices" value="Oui$Non"/>
|
||||
<property name="conclusion1" value="C'est triste mon Ami`$life-2``$power-5`"/>
|
||||
<property name="conclusion2" value="Dommage quand meme pour Lui."/>
|
||||
<property name="dialog" value="Quelqu'un est mort ici ... Tu le connais ?"/>
|
||||
<property name="isQuestion" type="int" value="1"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="2" name="PNJ1" type="NPC" x="252" y="164">
|
||||
<object id="2" name="PNJ2" type="NPC" x="164" y="132">
|
||||
<properties>
|
||||
<property name="dialog" value="Salut, je suis un PNJ"/>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Salut Hero, j'habite ici."/>
|
||||
<property name="hasPath" type="int" value="0"/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
<property name="path" type="object" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="10" name="PNJ1" type="NPC" x="252" y="164">
|
||||
<properties>
|
||||
<property name="choices" value="Oui$Non"/>
|
||||
<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>
|
||||
<object id="4" name="SGN1" type="SGN" x="96" y="136">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Indication sur le panneau. Bienvenue dans la maison du Tondu ..."/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="5" name="SGN2" type="SGN" x="288" y="128">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Indication sur le panneau. Entree dans le Sanctuaire Maudit ..."/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="9" name="TRJ1" type="TRJ" x="251.967" y="164.12">
|
||||
<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>
|
||||
|
|
|
@ -89,7 +89,11 @@
|
|||
<objectgroup id="4" name="ExtraData">
|
||||
<object id="1" name="INFO1" type="INFO" x="303.75" y="143.25">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Le tombeau du Chevalier Legendaire"/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
|
|
|
@ -89,19 +89,31 @@
|
|||
<objectgroup id="4" name="ExtraData">
|
||||
<object id="1" name="INFO1" type="INFO" x="128" y="87.5">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Encore une tombe ..."/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="2" name="INFO2" type="INFO" x="262.75" y="49">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Un passage souterrain ..."/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="3" name="SGN1" type="SGN" x="296" y="143.75">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="C'est la maison du gardien du cimetiere"/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
|
|
|
@ -89,31 +89,51 @@
|
|||
<objectgroup id="4" name="ExtraData">
|
||||
<object id="1" name="SGN5" type="SGN" x="224" y="183.25">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Maison du Maire"/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="5" name="SGN4" type="SGN" x="320.5" y="159.25">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Maison du Boulanger"/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="3" name="SGN3" type="SGN" x="184.25" y="95.75">
|
||||
<properties>
|
||||
<property name="dialog" value="Maison du Boucher"/>
|
||||
<property name="choices" value="Oui$Non"/>
|
||||
<property name="conclusion1" value="Super te voila requinque."/>
|
||||
<property name="conclusion2" value="J'aime pas la viande."/>
|
||||
<property name="dialog" value="Maison du Boucher. Tu veux un steak ?"/>
|
||||
<property name="isQuestion" type="int" value="1"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="4" name="SGN2" type="SGN" x="343.75" y="80">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Maison du Marechal Ferrand"/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="2" name="SGN1" type="SGN" x="71.75" y="143.25">
|
||||
<properties>
|
||||
<property name="choices" value="_"/>
|
||||
<property name="conclusion1" value="_"/>
|
||||
<property name="conclusion2" value="_"/>
|
||||
<property name="dialog" value="Maison du Fermier"/>
|
||||
<property name="isQuestion" type="int" value="0"/>
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <gint/cpu.h>
|
||||
#include <gint/display.h>
|
||||
|
||||
#include "npc.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
extern bopti_image_t SignAction_img;
|
||||
|
@ -58,6 +59,7 @@ void render_indicator(Game *game)
|
|||
void draw(Game *game) {
|
||||
/* Draw everything. */
|
||||
render_map_by_layer(game, BACKGROUND);
|
||||
npc_draw( game );
|
||||
player_draw(game);
|
||||
render_map_by_layer(game, FOREGROUND);
|
||||
render_indicator( game );
|
||||
|
|
35
src/game.h
|
@ -44,31 +44,46 @@ 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;
|
||||
|
||||
/* 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;
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
68
src/npc.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
#include "npc.h"
|
||||
#include "dialogs.h"
|
||||
#include "game.h"
|
||||
#include "map.h"
|
||||
#include "config.h"
|
||||
#include <gint/display.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
extern bopti_image_t demo_PNJ_img;
|
||||
|
||||
|
||||
/* the color of the text to go to the next dialog phase */
|
||||
/* it improves readability to have somathing lighter */
|
||||
#if defined(FXCG50)
|
||||
#define PATH_COLOR C_RED
|
||||
#else
|
||||
#define PATH_COLOR C_BLACK
|
||||
#endif
|
||||
|
||||
|
||||
void npc_draw(Game *game) {
|
||||
Player *player = &game->player;
|
||||
|
||||
for (int u=0; u<game->map_level->nbextradata; u++)
|
||||
{
|
||||
ExtraData *Data = &game->map_level->extradata[u];
|
||||
|
||||
if (strcmp(Data->type, "NPC")==0) /* the current data is a NPC */
|
||||
{
|
||||
|
||||
/* TODO : This is for debugging purpose, JUste to render the path */
|
||||
/* to be followed by the NPC when this will be implemented */
|
||||
if (Data->hasPath==1) /* this NPC has a trajectory */
|
||||
{
|
||||
int NbPoints = Data->path_length;
|
||||
for(int v=0; v<NbPoints; v++)
|
||||
{
|
||||
|
||||
/*
|
||||
int16_t deltaX1=((int16_t) (Data->xpath[v % NbPoints] * PXSIZE))-(int16_t) player->wx;
|
||||
int16_t deltaY1=((int16_t) (Data->ypath[v % NbPoints] * PXSIZE))-(int16_t) player->wy;
|
||||
|
||||
int16_t deltaX2=((int16_t) (Data->xpath[(v+1) % NbPoints] * PXSIZE))-(int16_t) player->wx;
|
||||
int16_t deltaY2=((int16_t) (Data->ypath[(v+1) % NbPoints] * PXSIZE))-(int16_t) player->wy;
|
||||
|
||||
dline( player->px + deltaX1, player->py + deltaY1,
|
||||
player->px + deltaX2, player->py + deltaY2,
|
||||
PATH_COLOR);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int16_t deltaX=((int16_t) (Data->x * PXSIZE))-(int16_t) player->wx;
|
||||
int16_t deltaY=((int16_t) (Data->y * PXSIZE))-(int16_t) player->wy;
|
||||
dimage( player->px-P_WIDTH/2+deltaX,
|
||||
player->py-P_HEIGHT/2+deltaY,
|
||||
&demo_PNJ_img);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
18
src/npc.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef NPC_H
|
||||
#define NPC_H
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "game.h"
|
||||
#include "memory.h"
|
||||
|
||||
|
||||
|
||||
/* Draws the player player. This function should be called after drawing the
|
||||
* map! */
|
||||
void npc_draw(Game *game);
|
||||
|
||||
|
||||
#endif
|
||||
|
34
src/player.c
|
@ -1,5 +1,6 @@
|
|||
#include "player.h"
|
||||
#include "dialogs.h"
|
||||
#include "game.h"
|
||||
#include "map.h"
|
||||
#include "config.h"
|
||||
#include <gint/display.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|