2021-08-06 23:42:49 +02:00
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/keyboard.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "character.h"
|
2021-08-15 02:42:26 +02:00
|
|
|
#include "engine.h"
|
|
|
|
#include "map.h"
|
2021-08-17 22:19:19 +02:00
|
|
|
#include "util.h"
|
2021-08-15 02:42:26 +02:00
|
|
|
|
2021-08-15 03:46:49 +02:00
|
|
|
struct Character character_default = {
|
2021-08-15 02:42:26 +02:00
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.name = "default name",
|
|
|
|
.dialog = "default dialog"
|
|
|
|
};
|
2021-08-06 23:42:49 +02:00
|
|
|
|
2021-08-08 01:43:26 +02:00
|
|
|
/*draw the dialog of a specified character*/
|
2021-08-15 03:46:49 +02:00
|
|
|
void draw_dialog(struct Character *character) {
|
2021-08-17 22:19:19 +02:00
|
|
|
const char *delim = ";";
|
|
|
|
|
|
|
|
char *str = strdup(character->dialog);
|
|
|
|
char *curr_line = strtok(str, delim);
|
|
|
|
|
|
|
|
while(curr_line != NULL) {
|
|
|
|
drect(20,10,370,80,C_WHITE);
|
|
|
|
dprint(25,20, C_BLACK, "%s", character->name);
|
|
|
|
dprint(25,40, C_BLACK, "%s", curr_line);
|
|
|
|
dupdate();
|
|
|
|
curr_line = strtok(NULL, delim);
|
|
|
|
wait_for_input(KEY_SHIFT);
|
2021-08-08 01:43:26 +02:00
|
|
|
}
|
2021-08-06 23:42:49 +02:00
|
|
|
}
|
|
|
|
|
2021-08-08 01:43:26 +02:00
|
|
|
/*find the character using the player's position*/
|
2021-08-15 03:46:49 +02:00
|
|
|
struct Character* get_character_xy(struct Character *characters[], int x, int y) {
|
2021-08-06 23:42:49 +02:00
|
|
|
int i = 0;
|
|
|
|
while(strcmp(characters[i]->name,"default name") != 0) {
|
|
|
|
if(characters[i]->x == x && characters[i]->y == y) return characters[i];
|
|
|
|
i++;
|
|
|
|
}
|
2021-08-15 02:42:26 +02:00
|
|
|
return &character_default;
|
|
|
|
}
|
|
|
|
|
2021-08-15 03:10:05 +02:00
|
|
|
/*get the characters for a specified map*/
|
2021-08-15 03:46:49 +02:00
|
|
|
struct Character** get_map_characters(int id) {
|
2021-08-15 02:42:26 +02:00
|
|
|
if(id == 1) {
|
2021-08-15 03:46:49 +02:00
|
|
|
extern struct Character character_Tituya;
|
|
|
|
extern struct Character character_Lephenixnoir;
|
|
|
|
extern struct Character character_Tituya2;
|
|
|
|
extern struct Character character_KikooDX;
|
|
|
|
extern struct Character character_Massena;
|
|
|
|
extern struct Character character_PancarteVille;
|
2021-08-15 02:42:26 +02:00
|
|
|
|
2021-08-15 03:46:49 +02:00
|
|
|
static struct Character *characters[] = {
|
2021-08-15 02:42:26 +02:00
|
|
|
&character_Tituya,
|
|
|
|
&character_Lephenixnoir,
|
|
|
|
&character_Massena,
|
|
|
|
&character_Tituya2,
|
|
|
|
&character_KikooDX,
|
|
|
|
&character_PancarteVille,
|
|
|
|
&character_default,
|
|
|
|
};
|
|
|
|
return characters;
|
|
|
|
}
|
2021-08-15 03:46:49 +02:00
|
|
|
static struct Character *characters[] = {};
|
2021-08-15 02:42:26 +02:00
|
|
|
return characters;
|
2021-08-15 03:46:49 +02:00
|
|
|
}
|