mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-05-30 09:38:33 +00:00
marge and fixing mia size
This commit is contained in:
+1
-1
@@ -298,7 +298,7 @@ add_executable(my_rpg
|
||||
include/components/attack_component.h
|
||||
src/systems/combat_methods.c
|
||||
src/combat/attacks.c
|
||||
src/player_utilities.c include/player_utilities.h src/systems/inventory.c include/systems/inventory.h src/systems/game_over.c include/systems/game_over.h)
|
||||
src/player_utilities.c include/player_utilities.h src/systems/inventory.c include/systems/inventory.h src/systems/game_over.c include/systems/game_over.h src/npc/mia.c lib/gamacon/src/scene/scene_constructor.c)
|
||||
|
||||
add_compile_options(-W -Wall -Wextra -Wshadow)
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
+9
-1
@@ -61,4 +61,12 @@ void water_jet(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
void shield(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
void enemy_attack(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
|
||||
void load_attacks(gc_scene *scene);
|
||||
void load_attacks(gc_scene *scene);
|
||||
|
||||
|
||||
bool mia_heal(gc_engine *engine, gc_entity *entity, \
|
||||
gc_vector2 pos, enum gc_mousekeys key);
|
||||
void mia_setup(gc_engine *engine);
|
||||
|
||||
void load_data(gc_scene *scene, const gc_data *datas);
|
||||
extern const struct gc_data game_data[];
|
||||
+1
-1
Submodule lib/gamacon updated: c9e77951c8...1715d0ecd3
@@ -144,6 +144,7 @@
|
||||
|
||||
<sprite name="farmer1" src="assets/sprites/npc/farmer1.png" />
|
||||
<sprite name="mayor" src="assets/sprites/npc/mayor.png" />
|
||||
<sprite name="mia" src="assets/sprites/npc/mia.png" />
|
||||
|
||||
<enemies>
|
||||
<enemy name="bee" src="prefabs/enemies/bee.gcprefab" spawn_rate="17%" />
|
||||
@@ -215,6 +216,25 @@
|
||||
</dialog_holder>
|
||||
</gc_entity>
|
||||
|
||||
<gc_entity>
|
||||
<transform_component>
|
||||
<Position x="0" y="0" />
|
||||
<Size x="70" y="90" />
|
||||
</transform_component>
|
||||
<renderer src="mia">
|
||||
<Rect height="32" width="24" top="64" left="24" />
|
||||
</renderer>
|
||||
<map_linker x="23" y="37" />
|
||||
<dialog_holder x="23" y="36" tile_texture="npc_interact">
|
||||
<Mia line="Oh, Hero! I'm grateful \nfor your visit." callback="mia_setup" />
|
||||
<Mia line="Do you want something?" >
|
||||
<input text="Heal me" click="mia_heal" />
|
||||
<input text="Save game" click="mia_save" />
|
||||
<input text="Fisherman" click="mia_fisherman" />
|
||||
<input text="Bye" />
|
||||
</Mia>
|
||||
</dialog_holder>
|
||||
</gc_entity>
|
||||
|
||||
<gc_entity>
|
||||
<transform_component>
|
||||
|
||||
@@ -55,29 +55,42 @@ static void ctr(void *component, va_list args)
|
||||
setup_tile_interactions(cmp, scene, (gc_vector2i){x, y}, texture);
|
||||
}
|
||||
|
||||
bool dialog_parse_inputs(struct dialog_line *txt, gc_scene *scene, node *n)
|
||||
{
|
||||
char *click;
|
||||
int i = 0;
|
||||
|
||||
txt->inputs = malloc(sizeof(struct dialog_input) * txt->input_count);
|
||||
if (!txt->inputs)
|
||||
return (false);
|
||||
for (n = n->child; n; n = n->next) {
|
||||
txt->inputs[i].text = xml_getproperty(n, "text");
|
||||
click = xml_gettempprop(n, "click");
|
||||
txt->inputs[i].callback = scene->get_data(scene, "input", click);
|
||||
if (!txt->inputs[i++].callback && click)
|
||||
my_printf("Couldn't find an input with the name: %s.\n", click);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
struct dialog_line *dialog_parse_text(gc_scene *scene, node *n)
|
||||
{
|
||||
struct dialog_line *txt = malloc(sizeof(struct dialog_line));
|
||||
char *click;
|
||||
int i = 0;
|
||||
char *callback;
|
||||
|
||||
if (!txt)
|
||||
return (NULL);
|
||||
txt->name = my_strdup(n->name);
|
||||
txt->text = xml_getproperty(n, "line");
|
||||
txt->input_count = xml_getchildcount_filtered(n, "input");
|
||||
txt->callback = NULL;
|
||||
callback = xml_gettempprop(n, "callback");
|
||||
txt->callback = scene->get_data(scene, "dialog_callback", callback);
|
||||
if (callback && !txt->callback)
|
||||
my_printf("Couldn't find an callback with the name: %s.\n", callback);
|
||||
txt->inputs = NULL;
|
||||
if (txt->input_count == 0)
|
||||
return (txt);
|
||||
txt->inputs = malloc(sizeof(struct dialog_input) * txt->input_count);
|
||||
for (n = n->child; n; n = n->next) {
|
||||
txt->inputs[i].text = xml_getproperty(n, "text");
|
||||
click = xml_gettempprop(n, "click");
|
||||
txt->inputs[i++].callback = scene->get_data(scene, "input", click);
|
||||
if (!txt->inputs)
|
||||
my_printf("Couldn't find a callback with the name: %s.\n", click);
|
||||
}
|
||||
dialog_parse_inputs(txt, scene, n);
|
||||
return (txt);
|
||||
}
|
||||
|
||||
|
||||
+25
-12
@@ -47,9 +47,16 @@ const struct callback callbacks[] = {
|
||||
{"action2", &dialog_input2},
|
||||
{"action3", &dialog_input3},
|
||||
{"hide_game_over", &hide_game_over},
|
||||
{"mia_heal", &mia_heal},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
const struct gc_data game_data[] = {
|
||||
{"input", "mia_heal", &mia_heal, NULL},
|
||||
{"dialog_callback", "mia_setup", &mia_setup, NULL},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
const struct callback map_editor_callbacks[] = {
|
||||
{"map_manage_click", &map_onclick},
|
||||
{"tile_select", &tile_select},
|
||||
@@ -64,10 +71,10 @@ const struct callback map_editor_callbacks[] = {
|
||||
};
|
||||
|
||||
const struct gc_data attacks[] = {
|
||||
{"attack", "Uppercut", &uppercut, NULL},
|
||||
{"attack", "Fireball", &fireball, NULL},
|
||||
{"attack", "Water jet", &water_jet, NULL},
|
||||
{"attack", "Shield", &shield, NULL},
|
||||
{"attack", "Uppercut", &uppercut, NULL},
|
||||
{"attack", "Fireball", &fireball, NULL},
|
||||
{"attack", "Water jet", &water_jet, NULL},
|
||||
{"attack", "Shield", &shield, NULL},
|
||||
{"attack", "Aerial attack", &enemy_attack, NULL},
|
||||
{"attack", "Spore attack", &enemy_attack, NULL},
|
||||
{"attack", "Sharp leaves", &enemy_attack, NULL},
|
||||
@@ -77,22 +84,28 @@ const struct gc_data attacks[] = {
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
void load_attacks(gc_scene *scene)
|
||||
void load_data(gc_scene *scene, const gc_data *datas)
|
||||
{
|
||||
gc_data *data;
|
||||
gc_list *li = scene->get_entity_by_cmp(scene, "attack_component");
|
||||
struct attack_component *att;
|
||||
|
||||
for (int i = 0; attacks[i].name; i++) {
|
||||
for (int i = 0; datas[i].name; i++) {
|
||||
data = malloc(sizeof(*data));
|
||||
if (!data)
|
||||
return;
|
||||
data->name = my_strdup(attacks[i].name);
|
||||
data->type = my_strdup(attacks[i].type);
|
||||
data->custom = attacks[i].custom;
|
||||
data->destroy = attacks[i].destroy;
|
||||
data->name = my_strdup(datas[i].name);
|
||||
data->type = my_strdup(datas[i].type);
|
||||
data->custom = datas[i].custom;
|
||||
data->destroy = datas[i].destroy;
|
||||
LISTADD(scene->data, data);
|
||||
}
|
||||
}
|
||||
|
||||
void load_attacks(gc_scene *scene)
|
||||
{
|
||||
gc_list *li = scene->get_entity_by_cmp(scene, "attack_component");
|
||||
struct attack_component *att;
|
||||
|
||||
load_data(scene, attacks);
|
||||
for (; li; li = li->next) {
|
||||
att = GETCMP(li->data, attack_component);
|
||||
for (int i = 0; att->attacks && att->attacks[i].name; i++)
|
||||
|
||||
+5
-5
@@ -19,18 +19,18 @@ enum gc_mousekeys __)
|
||||
|
||||
prefab_load(engine, "prefabs/loading.gcprefab");
|
||||
engine->game_loop(engine, 0);
|
||||
scene = scene_create(engine, "prefabs/game.gcprefab");
|
||||
scene = scene_new(engine);
|
||||
load_data(scene, game_data);
|
||||
scene = scene_parse_xml(scene, engine, "prefabs/game.gcprefab");
|
||||
if (!scene) {
|
||||
engine->should_close = true;
|
||||
my_printf("The game scene couldn't be loaded.\n");
|
||||
return (true);
|
||||
}
|
||||
engine->change_scene(engine, scene);
|
||||
if (prefab_load(engine, "prefabs/player.gcprefab") < 0) {
|
||||
if (prefab_load(engine, "prefabs/player.gcprefab") < 0)
|
||||
my_printf("Could not load the player.\n");
|
||||
return (true);
|
||||
}
|
||||
if (prefab_load(engine, "prefabs/map_entities.gcprefab") < 0)
|
||||
else if (prefab_load(engine, "prefabs/map_entities.gcprefab") < 0)
|
||||
return (true);
|
||||
if (engine->get_callback(engine, "map_manage_click"))
|
||||
if (prefab_load(engine, "prefabs/editor_ui.gcprefab") < 0)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** my_rpg
|
||||
** File description:
|
||||
** mia.c
|
||||
*/
|
||||
|
||||
#include <components/health_component.h>
|
||||
#include <components/dialog_holder.h>
|
||||
#include "engine.h"
|
||||
|
||||
struct dialog_holder *dialog_get_current(gc_engine *engine)
|
||||
{
|
||||
struct dialog_manager *manager = GETSYS(engine, dialog_manager);
|
||||
|
||||
return (manager->current_dialog);
|
||||
}
|
||||
|
||||
void mia_setup(gc_engine *engine)
|
||||
{
|
||||
struct dialog_holder *holder = dialog_get_current(engine);
|
||||
|
||||
holder->text[2] = NULL;
|
||||
}
|
||||
|
||||
bool mia_heal(gc_engine *engine, gc_entity *entity, \
|
||||
gc_vector2 pos, enum gc_mousekeys key)
|
||||
{
|
||||
gc_entity *player = engine->scene->get_entity(engine->scene, 50);
|
||||
struct health_component *hea;
|
||||
struct dialog_holder *dialog = dialog_get_current(engine);
|
||||
|
||||
if (!player || !dialog)
|
||||
return (false);
|
||||
hea = GETCMP(player, health_component);
|
||||
if (!hea)
|
||||
return (false);
|
||||
if (hea->health != hea->health_max) {
|
||||
hea->health = hea->health_max;
|
||||
dialog_add_line(dialog, "Mia", "Of course, let me\
|
||||
take care\nof it.", NULL);
|
||||
} else {
|
||||
dialog_add_line(dialog, "Mia", "You don't seem to have\n\
|
||||
any wounds.", NULL);
|
||||
dialog_add_line(dialog, "Mia", "Are you sure you are\n\
|
||||
here for that?", NULL);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
Reference in New Issue
Block a user