mirror of https://github.com/bgiraudr/Adoranda.git
add basic character dialog
This commit is contained in:
parent
d851e5f24b
commit
0ec0452568
|
@ -3,7 +3,7 @@
|
|||
/build-cg
|
||||
/*.g1a
|
||||
/*.g3a
|
||||
*.json
|
||||
/*.json
|
||||
|
||||
# Python bytecode
|
||||
__pycache__/
|
||||
|
|
|
@ -24,12 +24,14 @@ set(SOURCES
|
|||
src/game.c
|
||||
src/engine.c
|
||||
src/animation.c
|
||||
src/character.c
|
||||
)
|
||||
|
||||
set(ASSETS_cg
|
||||
assets-cg/tileset.png
|
||||
assets-cg/maps/testCarte.json
|
||||
assets-cg/spritesheet.png
|
||||
assets-cg/characters/Tituya.char
|
||||
)
|
||||
|
||||
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
39
|
||||
30
|
||||
Tituya
|
||||
Salut ! Ça va bien ? hé
|
|
@ -0,0 +1,3 @@
|
|||
*.char:
|
||||
custom-type: character
|
||||
name_regex: (.*)\.char character_\1
|
|
@ -5,6 +5,9 @@ def convert(input, output, params, target):
|
|||
if params["custom-type"] == "map":
|
||||
convert_map(input, output, params, target)
|
||||
return 0
|
||||
elif params["custom-type"] == "character":
|
||||
convert_character(input, output, params, target)
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
|
@ -12,6 +15,7 @@ def convert_map(input, output, params, target):
|
|||
TILE_AIR = 0
|
||||
TILE_SOLID = 1
|
||||
TILE_DOOR = 2
|
||||
TILE_CHARACTER = 3
|
||||
|
||||
with open(input, "r") as jsonData:
|
||||
data = json.load(jsonData)
|
||||
|
@ -34,6 +38,8 @@ def convert_map(input, output, params, target):
|
|||
value = TILE_SOLID
|
||||
elif type == "door":
|
||||
value = TILE_DOOR
|
||||
elif type == "character":
|
||||
value = TILE_CHARACTER
|
||||
else:
|
||||
value = TILE_AIR
|
||||
|
||||
|
@ -65,4 +71,16 @@ def convert_map(input, output, params, target):
|
|||
else:
|
||||
raise fxconv.FxconvError(f"There is too much layer ! {nblayer} found for a max of 2")
|
||||
|
||||
fxconv.elf(o, output, "_" + params["name"], **target)
|
||||
|
||||
def convert_character(input, output, params, target):
|
||||
with open(input,"r") as dialog:
|
||||
file = dialog.read().splitlines()
|
||||
|
||||
o = fxconv.ObjectData()
|
||||
o += fxconv.u32((int)(file[0])) + fxconv.u32((int)(file[1]))
|
||||
o += fxconv.ref(bytes(file[2], 'utf-8') + bytes(1))
|
||||
o += fxconv.ref(bytes(file[3], 'utf-8') + bytes(1))
|
||||
|
||||
|
||||
fxconv.elf(o, output, "_" + params["name"], **target)
|
|
@ -1,8 +1,12 @@
|
|||
tileset.png:
|
||||
type: bopti-image
|
||||
name: img_tileset
|
||||
profile:p8
|
||||
profile:p4
|
||||
|
||||
spritesheet.png:
|
||||
type: bopti-image
|
||||
name: img_spritesheet
|
||||
|
||||
dialog.txt:
|
||||
custom-type: dialog
|
||||
name: dialog_1
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -54,8 +54,8 @@
|
|||
663,664,665,666,667,0,117,118,119,485,486,487,19,20,21,431,432,433,434,435,13,0,0,106,0,10,108,246,247,0,0,281,190,191,0,159,160,0,0,0,0,0,0,0,0,0,0,0,0,0,149,150,151,159,160,0,
|
||||
692,693,694,695,696,211,212,0,0,215,216,217,218,0,0,460,461,462,463,464,19,20,21,106,10,0,108,157,158,0,0,0,219,220,0,188,189,0,0,0,0,0,0,281,281,0,0,0,0,0,178,179,180,188,189,0,
|
||||
721,722,723,724,725,240,241,0,0,244,245,246,247,163,164,489,490,491,492,493,274,275,276,106,23,0,108,186,187,0,149,150,151,0,0,0,0,0,0,0,0,0,0,281,0,0,0,0,0,0,207,208,209,0,0,0,
|
||||
750,751,0,753,754,593,594,595,596,0,0,0,0,192,193,518,519,520,521,522,303,304,305,106,0,0,108,217,218,0,178,179,180,0,0,0,0,0,0,0,0,0,0,281,0,0,0,0,0,0,236,237,238,0,0,0,
|
||||
0,19,0,593,594,595,596,0,0,593,594,595,596,221,222,547,0,549,550,551,332,333,334,106,0,23,108,246,247,0,207,208,209,0,0,0,281,0,0,0,0,0,0,281,0,159,160,0,0,0,0,0,0,0,0,0,
|
||||
750,751,224,753,754,593,594,595,596,0,0,0,0,192,193,518,519,520,521,522,303,304,305,106,0,0,108,217,218,0,178,179,180,0,0,0,0,0,0,0,0,0,0,281,0,0,0,0,0,0,236,237,238,0,0,0,
|
||||
0,19,253,593,594,595,596,0,0,593,594,595,596,221,222,547,0,549,550,551,332,333,334,106,0,23,108,246,247,0,207,208,209,0,0,0,281,0,0,0,0,0,0,281,0,159,160,0,0,0,0,0,0,0,0,0,
|
||||
0,16,0,15,21,19,14,18,19,19,14,15,19,18,13,21,0,19,677,0,361,362,363,135,136,136,137,243,185,0,236,237,238,0,0,0,281,0,0,0,0,0,0,281,0,188,189,0,0,0,0,281,281,0,0,0,
|
||||
0,19,0,0,0,0,281,281,0,0,0,0,0,0,0,0,0,16,706,619,576,577,578,579,580,0,595,595,0,0,0,0,0,281,281,281,281,0,0,0,0,0,0,0,0,0,0,0,0,0,0,281,0,0,0,0,
|
||||
0,14,18,19,14,16,19,0,0,17,21,15,19,19,19,17,0,19,619,0,605,606,607,608,609,0,595,595,0,0,0,0,0,0,0,0,0,0,0,0,0,281,281,0,161,162,0,0,0,0,0,281,281,0,0,0,
|
||||
|
@ -72,13 +72,13 @@
|
|||
16,0,0,0,0,95,252,252,252,252,95,306,307,308,0,19,20,0,14,13,0,0,19,16,19,19,15,19,20,326,327,328,0,120,121,122,535,0,0,0,0,0,0,0,98,98,92,92,0,0,509,510,511,355,356,357,
|
||||
16,277,278,279,0,95,252,252,252,252,95,335,336,337,0,15,21,0,19,0,0,0,0,0,0,19,20,509,510,511,356,357,0,17,20,15,535,0,113,0,113,0,0,0,0,98,92,92,0,0,538,539,540,0,0,0,
|
||||
0,306,307,308,0,95,252,252,252,252,95,364,365,366,69,69,70,21,21,0,535,535,0,0,535,535,0,538,539,540,0,0,0,15,19,535,535,0,113,113,113,0,0,0,0,98,98,92,92,0,0,77,78,78,78,78,
|
||||
0,335,336,337,0,0,0,0,0,0,0,0,0,19,20,21,99,13,16,0,535,535,393,394,395,0,21,20,0,0,68,69,70,0,535,535,346,347,348,113,113,0,0,594,0,0,98,98,98,0,0,106,0,0,0,0,
|
||||
0,364,365,366,0,0,0,0,0,0,0,19,20,21,20,21,99,21,16,0,535,593,422,423,424,0,0,0,0,0,97,98,99,0,373,374,375,376,113,113,113,0,535,536,536,0,0,0,19,21,0,106,0,80,81,82,
|
||||
0,335,336,337,0,0,224,0,0,0,0,0,0,19,20,21,99,13,16,0,535,535,393,394,395,0,21,20,0,0,68,69,70,0,535,535,346,347,348,113,113,0,0,594,0,0,98,98,98,0,0,106,0,0,0,0,
|
||||
0,364,365,366,0,0,253,0,0,0,0,19,20,21,20,21,99,21,16,0,535,593,422,423,424,0,0,0,0,0,97,98,99,0,373,374,375,376,113,113,113,0,535,536,536,0,0,0,19,21,0,106,0,80,81,82,
|
||||
157,158,0,0,0,0,0,0,0,0,0,0,0,509,510,511,99,0,15,0,535,537,451,452,453,0,0,0,0,0,126,127,128,0,402,403,404,405,406,113,113,0,593,536,593,0,0,14,21,0,16,106,0,109,110,111,
|
||||
186,187,0,0,0,0,0,0,0,0,0,0,0,538,539,540,99,0,19,0,535,536,480,481,482,0,0,0,0,0,20,0,0,0,431,432,433,434,435,113,113,13,536,535,535,0,0,15,19,19,16,106,0,138,139,140,
|
||||
19,20,21,0,0,0,595,594,535,536,537,565,0,0,0,0,99,0,20,0,595,595,0,0,0,0,0,0,0,0,19,19,20,0,460,461,462,463,464,0,113,18,535,594,593,0,17,16,0,21,0,106,0,0,0,0,
|
||||
157,158,0,0,0,0,595,564,567,593,567,535,0,0,0,21,99,21,19,0,535,535,0,0,535,535,0,0,18,17,17,19,19,0,489,490,491,492,493,0,113,0,595,593,536,0,0,0,19,19,0,106,0,0,0,0,
|
||||
186,187,0,0,0,0,595,536,536,566,564,566,0,0,0,21,99,19,0,0,535,535,0,0,593,593,535,0,0,0,16,19,19,0,518,519,520,521,522,0,113,0,535,595,535,0,0,268,269,270,0,106,80,81,82,0,
|
||||
157,158,0,0,0,0,595,564,567,593,567,535,0,0,0,21,99,21,19,0,535,535,0,0,535,535,0,0,18,17,17,19,19,0,489,490,491,492,493,224,113,0,595,593,536,0,0,0,19,19,0,106,0,0,0,0,
|
||||
186,187,0,0,0,0,595,536,536,566,564,566,0,0,0,21,99,19,0,0,535,535,0,0,593,593,535,0,0,0,16,19,19,0,518,519,520,521,522,253,113,0,535,595,535,0,0,268,269,270,0,106,80,81,82,0,
|
||||
0,0,0,0,0,0,0,0,0,564,596,595,0,0,0,21,99,0,0,0,0,0,0,0,535,595,535,0,0,0,13,0,0,0,547,548,549,550,551,0,0,0,536,595,594,0,0,297,298,299,0,106,109,110,111,0,
|
||||
18,14,278,279,0,0,0,0,0,596,537,535,0,0,0,0,95,0,0,0,0,0,0,0,535,537,594,535,0,0,0,0,0,0,0,0,0,0,0,0,0,0,594,594,595,0,16,326,327,328,535,106,138,139,140,0,
|
||||
0,306,307,308,0,0,0,0,0,594,596,566,0,0,0,0,95,393,394,395,0,0,0,0,535,535,536,595,535,535,535,535,535,535,535,535,537,537,535,593,537,595,594,595,0,0,535,355,356,357,535,106,0,0,0,0,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -55,6 +55,7 @@
|
|||
<tile id="244" type="solid"/>
|
||||
<tile id="245" type="solid"/>
|
||||
<tile id="246" type="solid"/>
|
||||
<tile id="252" type="character"/>
|
||||
<tile id="261" type="solid"/>
|
||||
<tile id="262" type="solid"/>
|
||||
<tile id="263" type="solid"/>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
|
@ -0,0 +1,8 @@
|
|||
struct character {
|
||||
int x, y;
|
||||
char *name;
|
||||
char *dialog;
|
||||
};
|
||||
|
||||
void draw_dialog(struct character *character);
|
||||
struct character* get_character_xy(struct character *characters[], int x, int y);
|
|
@ -1,2 +1,2 @@
|
|||
#define PLAYER_VIEW_X 13
|
||||
#define PLAYER_VIEW_Y 8
|
||||
#define PLAYER_VIEW_X 5
|
||||
#define PLAYER_VIEW_Y 5
|
||||
|
|
|
@ -11,5 +11,6 @@ struct map {
|
|||
enum map_state {
|
||||
TILE_AIR = 0,
|
||||
TILE_SOLID = 1,
|
||||
TILE_DOOR = 2
|
||||
TILE_DOOR = 2,
|
||||
TILE_CHARACTER = 3,
|
||||
};
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <string.h>
|
||||
#include "character.h"
|
||||
|
||||
void draw_dialog(struct character *character) {
|
||||
dprint(1,20, C_BLACK, "(%d,%d)", character->x, character->y);
|
||||
dprint(1,40, C_BLACK, "%s", character->name);
|
||||
dprint(1,60, C_BLACK, "%s", character->dialog);
|
||||
}
|
||||
|
||||
struct character* get_character_xy(struct character *characters[], int x, int y) {
|
||||
int i = 0;
|
||||
while(strcmp(characters[i]->name,"default name") != 0) {
|
||||
if(characters[i]->x == x && characters[i]->y == y) return characters[i];
|
||||
i++;
|
||||
}
|
||||
return characters[i];
|
||||
}
|
|
@ -124,8 +124,8 @@ void engine_tick(struct game *game, int dt) {
|
|||
|
||||
int map_walkable(struct map const *map, int x, int y) {
|
||||
int tile = map->info_map[x + map->w * y];
|
||||
if(x < 0 || x > map->w-1 || y < 0 || y > map->h) return 0;
|
||||
return (tile != TILE_SOLID);
|
||||
if(x < 0 || x > map->w-1 || y < 0 || y > map->h-1) return 0;
|
||||
return (tile != TILE_SOLID && tile != TILE_CHARACTER);
|
||||
}
|
||||
|
||||
void engine_set_background(struct game *game, int color) {
|
||||
|
|
16
src/main.c
16
src/main.c
|
@ -5,6 +5,7 @@
|
|||
#include "engine.h"
|
||||
#include "player.h"
|
||||
#include "animation.h"
|
||||
#include "character.h"
|
||||
|
||||
#include <gint/timer.h>
|
||||
#include <gint/clock.h>
|
||||
|
@ -15,6 +16,20 @@ struct map *maps[] = {
|
|||
&map_1,
|
||||
};
|
||||
|
||||
extern struct character character_Tituya;
|
||||
|
||||
struct character character_default = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.name = "default name",
|
||||
.dialog = "default dialog"
|
||||
};
|
||||
|
||||
struct character *characters[] = {
|
||||
&character_Tituya,
|
||||
&character_default,
|
||||
};
|
||||
|
||||
static int callback_tick(volatile int *tick) {
|
||||
*tick = 1;
|
||||
return TIMER_CONTINUE;
|
||||
|
@ -49,6 +64,7 @@ int main(void) {
|
|||
tick = 0;
|
||||
|
||||
engine_draw(&game);
|
||||
draw_dialog(get_character_xy(characters, 39, 30));
|
||||
dupdate();
|
||||
|
||||
int dir = get_inputs();
|
||||
|
|
Loading…
Reference in New Issue