From 6a63de4a637a02e998852fc17a47df912b04ca93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Wed, 1 Apr 2020 12:26:29 +0200 Subject: [PATCH] added an health component --- CMakeLists.txt | 2 +- include/components/health_component.h | 22 ++++++++++ src/components/health_component.c | 62 +++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 include/components/health_component.h create mode 100644 src/components/health_component.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 3830e55..af1ef85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,7 +252,7 @@ add_executable(my_rpg src/systems/map_movement_system.c lib/gamacon/src/components/renderers/anim_utils.c lib/gamacon/src/isometry/map_utilities.c - lib/gamacon/src/sfml_renderer/sfml_utilities.c lib/gamacon/src/components/map_linker.c lib/gamacon/include/components/map_linker.h lib/gamacon/src/systems/map_linker_system.c) + lib/gamacon/src/sfml_renderer/sfml_utilities.c lib/gamacon/src/components/map_linker.c lib/gamacon/include/components/map_linker.h lib/gamacon/src/systems/map_linker_system.c src/components/health_component.c include/components/health_component.h) add_compile_options(-W -Wall -Wextra -Wshadow) diff --git a/include/components/health_component.h b/include/components/health_component.h new file mode 100644 index 0000000..40c22cf --- /dev/null +++ b/include/components/health_component.h @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2019 +** Gamacon +** File description: +** health_component +*/ + +#ifndef MY_RPG_HEALTH_COMPONENT_H +#define MY_RPG_HEALTH_COMPONENT_H + +#include "component.h" +#include + +struct health_component +{ + gc_component base; + unsigned int health; +}; + +extern const struct health_component health_component; + +#endif //MY_RPG_HEALTH_COMPONENT_H diff --git a/src/components/health_component.c b/src/components/health_component.c new file mode 100644 index 0000000..8fb7277 --- /dev/null +++ b/src/components/health_component.c @@ -0,0 +1,62 @@ +/* +** EPITECH PROJECT, 2020 +** My3D +** File description: +** health component +*/ + +#include "xml.h" +#include "component.h" +#include "components/health_component.h" + +static void health_ctr(void *component, va_list args) +{ + struct controllable_component *cmp = (struct controllable_component *)\ +component; + + cmp->movement_x = 0; + cmp->movement_y = 0; + cmp->move_callback = 0; + (void)args; +} + +static void health_fdctr(gc_entity *entity, gc_scene *scene, \ +void *component, node *n) +{ + struct controllable_component *cmp = (struct controllable_component *)\ +component; + + cmp->movement_x = 0; + cmp->movement_y = 0; + cmp->move_callback = 0; + (void)scene; + (void)entity; + (void)n; +} + +static void health_dtr(void *component) +{ + (void)component; +} + +static char *health_serialize(void *component) +{ + (void)component; + return (NULL); +} + +const struct health_component health_component = { + base: { + name: "health_component", + size: sizeof(struct health_component), + dependencies: (char *[]){ + "event_component", + NULL + }, + ctr: &health_ctr, + fdctr: &health_fdctr, + dtr: &health_dtr, + serialize: &health_serialize, + destroy: &component_destroy + } +}; \ No newline at end of file