mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-29 13:03:43 +01:00
added representation of NPCs + finalized path importation for NPCs - data alignement issue to be solved
This commit is contained in:
parent
196cbb97ae
commit
8639a3feed
6 changed files with 138 additions and 12 deletions
|
@ -14,7 +14,7 @@ find_package(LibProf 2.4 REQUIRED)
|
||||||
#set the color mode either to 1b or 2b
|
#set the color mode either to 1b or 2b
|
||||||
set(COLORMODE_fx 2b)
|
set(COLORMODE_fx 2b)
|
||||||
#set the color mode either to 1b, 2b or EGA64
|
#set the color mode either to 1b, 2b or EGA64
|
||||||
set(COLORMODE_cg 1b)
|
set(COLORMODE_cg EGA64)
|
||||||
|
|
||||||
fxconv_declare_converters(assets/converters.py)
|
fxconv_declare_converters(assets/converters.py)
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ set(SOURCES
|
||||||
src/memory.c
|
src/memory.c
|
||||||
src/game.c
|
src/game.c
|
||||||
src/dialogs.c
|
src/dialogs.c
|
||||||
|
src/npc.c
|
||||||
# ...
|
# ...
|
||||||
)
|
)
|
||||||
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
|
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
|
||||||
|
|
|
@ -230,7 +230,6 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
#create the structure of the map
|
#create the structure of the map
|
||||||
structData = fxconv.Structure()
|
structData = fxconv.Structure()
|
||||||
|
|
||||||
|
|
||||||
nbExtraData = 0
|
nbExtraData = 0
|
||||||
layer = data["layers"][layer_extradata]
|
layer = data["layers"][layer_extradata]
|
||||||
for i in layer["objects"]:
|
for i in layer["objects"]:
|
||||||
|
@ -257,7 +256,6 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
xdata = None
|
xdata = None
|
||||||
ydata = None
|
ydata = None
|
||||||
|
|
||||||
|
|
||||||
#we now fill all the properties of this item
|
#we now fill all the properties of this item
|
||||||
for j in i["properties"]:
|
for j in i["properties"]:
|
||||||
#property "dialog"
|
#property "dialog"
|
||||||
|
@ -276,9 +274,30 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
#Extra properties for NPCs (path)
|
#Extra properties for NPCs (path)
|
||||||
if tpe=="NPC":
|
if tpe=="NPC":
|
||||||
if j["name"]=="hasPath":
|
if j["name"]=="hasPath":
|
||||||
|
pathID = None
|
||||||
path = j[ "value" ]
|
path = j[ "value" ]
|
||||||
if path==1: print( "PNJ has path" )
|
if path==1:
|
||||||
else: print( "PNJ has no Path" )
|
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:
|
else:
|
||||||
print( "UNIDENTIFIED PROPERTY : ", j["name"])
|
print( "UNIDENTIFIED PROPERTY : ", j["name"])
|
||||||
|
@ -297,10 +316,16 @@ def get_extra_map_data(input, output, params, target, xmin, ymin, xmax, ymax):
|
||||||
structData += fxconv.string( choi )
|
structData += fxconv.string( choi )
|
||||||
structData += fxconv.string( conc1 )
|
structData += fxconv.string( conc1 )
|
||||||
structData += fxconv.string( conc2 )
|
structData += fxconv.string( conc2 )
|
||||||
structData += fxconv.u32(0)
|
if path==0:
|
||||||
structData += fxconv.u32(0)
|
structData += fxconv.u32(0)
|
||||||
structData += fxconv.u32(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 we do nothing (yet)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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="10">
|
<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>
|
<editorsettings>
|
||||||
<export target="level0.json" format="json"/>
|
<export target="level0.json" format="json"/>
|
||||||
</editorsettings>
|
</editorsettings>
|
||||||
|
@ -120,7 +120,19 @@
|
||||||
</properties>
|
</properties>
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</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="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>
|
<properties>
|
||||||
<property name="choices" value="Oui$Non"/>
|
<property name="choices" value="Oui$Non"/>
|
||||||
<property name="conclusion1" value="Voici donc pour toi`$life+5``$mana+5``$power+2`"/>
|
<property name="conclusion1" value="Voici donc pour toi`$life+5``$mana+5``$power+2`"/>
|
||||||
|
@ -152,7 +164,7 @@
|
||||||
</properties>
|
</properties>
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
<object id="9" name="TRJ1" type="TRJ" x="251.75" y="165.25">
|
<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"/>
|
<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>
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <gint/cpu.h>
|
#include <gint/cpu.h>
|
||||||
#include <gint/display.h>
|
#include <gint/display.h>
|
||||||
|
|
||||||
|
#include "npc.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
extern bopti_image_t SignAction_img;
|
extern bopti_image_t SignAction_img;
|
||||||
|
@ -58,6 +59,7 @@ void render_indicator(Game *game)
|
||||||
void draw(Game *game) {
|
void draw(Game *game) {
|
||||||
/* Draw everything. */
|
/* Draw everything. */
|
||||||
render_map_by_layer(game, BACKGROUND);
|
render_map_by_layer(game, BACKGROUND);
|
||||||
|
npc_draw( game );
|
||||||
player_draw(game);
|
player_draw(game);
|
||||||
render_map_by_layer(game, FOREGROUND);
|
render_map_by_layer(game, FOREGROUND);
|
||||||
render_indicator( game );
|
render_indicator( game );
|
||||||
|
|
68
src/npc.c
Normal file
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
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
|
||||||
|
|
Loading…
Reference in a new issue