Listing attacks when the user should select one

This commit is contained in:
Anonymus Raccoon
2020-04-22 17:07:49 +02:00
parent dc403c0994
commit 4fc359ab5a
6 changed files with 31 additions and 9 deletions
+7 -2
View File
@@ -2,7 +2,7 @@
** EPITECH PROJECT, 2020
** my_rpg
** File description:
** attack_component.h
** attack_component.hMdr
*/
@@ -13,9 +13,14 @@
typedef void (*attack)(gc_entity *from, gc_entity *enemy);
typedef struct attack_holder {
char *name;
attack run;
} attack_holder;
struct attack_component {
gc_component base;
gc_data *attacks;
attack_holder *attacks;
};
extern const struct attack_component attack_component;
+4
View File
@@ -30,6 +30,10 @@
<map_linker x="0" y="0" />
<player_component />
<attack_component>
<attack name="Wind Slash" />
<attack name="Blizzard" />
<attack name="Fireball" />
<attack name="Water jet" />
</attack_component>
</gc_entity>
+4 -4
View File
@@ -1,6 +1,6 @@
<gc_entities>
<button text="ty" x="80%" y="61%" click="action0" color="black" width="20%" height="9%" size="24" text_id="35353500" />
<button text="ty 1" x="80%" y="69%" click="action1" color="black" width="20%" height="9%" size="24" text_id="35353501" />
<button text="ty 2" x="80%" y="77%" click="action2" color="black" width="20%" height="9%" size="24" text_id="35353502" />
<button text="ty 3" x="80%" y="85%" click="action3" color="black" width="20%" height="9%" size="24" text_id="35353503" />
<button text="???" x="80%" y="61%" click="action0" color="black" width="20%" height="9%" size="24" text_id="35353500" />
<button text="???" x="80%" y="69%" click="action1" color="black" width="20%" height="9%" size="24" text_id="35353501" />
<button text="???" x="80%" y="77%" click="action2" color="black" width="20%" height="9%" size="24" text_id="35353502" />
<button text="???" x="80%" y="85%" click="action3" color="black" width="20%" height="9%" size="24" text_id="35353503" />
</gc_entities>
+14 -2
View File
@@ -7,19 +7,31 @@
#include "engine.h"
#include "components/attack_component.h"
#include <malloc.h>
static void ctr(void *component, va_list args)
{
struct attack_component *cmp = (struct attack_component *)component;
cmp->attacks = va_arg(args, gc_data *);
cmp->attacks = va_arg(args, attack_holder *);
}
static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
{
struct attack_component *cmp = (struct attack_component *)component;
int i = 0;
char *name;
// SET ATTACKS FROM the xml.
cmp->attacks = malloc(sizeof(attack_holder) * xml_getchildcount(n));
if (!cmp->attacks)
return;
for (n = n->child; n; n = n->next) {
name = xml_getproperty(n, "name");
cmp->attacks[i].name = name;
cmp->attacks[i].run = scene->get_data(scene, "attack", name);
i++;
}
cmp->attacks[i].name = NULL;
}
static void dtr(void *component)
+1
View File
@@ -88,6 +88,7 @@ static bool handle_input(gc_engine *engine, struct dialog_manager *this)
((gc_text *)rend->data)->text = this->current_text->inputs[i].text;
rend->destroy = &text_safe_destroy;
}
this->input_index = 0;
return (true);
}