mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-05-29 17:31:56 +00:00
removing multiple mentions of files in Cmake
This commit is contained in:
+12
-1
@@ -252,7 +252,18 @@ 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 src/components/health_component.c include/components/health_component.h)
|
||||
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/include/tile.h
|
||||
src/components/dialog_holder.c
|
||||
include/components/dialog_holder.h
|
||||
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)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ SRC = src/main.c \
|
||||
src/components/map_movement.c \
|
||||
src/components/controllable_component.c \
|
||||
src/components/controllers/keyboard_controller.c \
|
||||
src/components/dialog_holder.c \
|
||||
src/systems/map_movement_system.c \
|
||||
src/systems/controllers/keyboard_controller_system.c
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** my_rpg
|
||||
** File description:
|
||||
** dialog_holder.h
|
||||
*/
|
||||
|
||||
#ifndef MY_RPG_DIALOG_HOLDER_H
|
||||
#define MY_RPG_DIALOG_HOLDER_H
|
||||
|
||||
#include "component.h"
|
||||
|
||||
struct dialog_holder {
|
||||
gc_component base;
|
||||
char **text;
|
||||
bool single_usage;
|
||||
bool has_seen;
|
||||
|
||||
int current_line;
|
||||
char *current_text;
|
||||
};
|
||||
|
||||
const struct dialog_holder dialog_holder;
|
||||
|
||||
#endif //MY_RPG_DIALOG_HOLDER_H
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** my_rpg
|
||||
** File description:
|
||||
** dialog_holder.c
|
||||
*/
|
||||
|
||||
#include "components/dialog_holder.h"
|
||||
#include <stddef.h>
|
||||
#include <malloc.h>
|
||||
|
||||
static void ctr(void *component, va_list args)
|
||||
{
|
||||
struct dialog_holder *cmp = (struct dialog_holder *)component;
|
||||
|
||||
cmp->text = va_arg(args, char **);
|
||||
cmp->single_usage = va_arg(args, int);
|
||||
cmp->has_seen = false;
|
||||
cmp->current_line = 0;
|
||||
cmp->current_text = NULL;
|
||||
}
|
||||
|
||||
static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
|
||||
{
|
||||
struct dialog_holder *cmp = (struct dialog_holder *)component;
|
||||
int count = xml_getchildcount(n);
|
||||
|
||||
cmp->single_usage = xml_getbool(n, "single_usage", false);
|
||||
cmp->text = malloc(sizeof(char *) * (count + 1));
|
||||
if (!cmp->text)
|
||||
return;
|
||||
n = n->child;
|
||||
for (int i = 0; n; n = n->next, i++)
|
||||
cmp->text[i] = xml_getproperty(n, "data");
|
||||
cmp->text[count] = NULL;
|
||||
}
|
||||
|
||||
static void dtr(void *component)
|
||||
{
|
||||
(void)component;
|
||||
}
|
||||
|
||||
static char *serialize(void *component)
|
||||
{
|
||||
(void)component;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const struct dialog_holder dialog_holder = {
|
||||
base: {
|
||||
name: "dialog_holder",
|
||||
size: sizeof(struct dialog_holder),
|
||||
dependencies: (char *[]){
|
||||
NULL
|
||||
},
|
||||
ctr: &ctr,
|
||||
fdctr: &fdctr,
|
||||
dtr: &dtr,
|
||||
serialize: &serialize,
|
||||
destroy: &component_destroy
|
||||
}
|
||||
};
|
||||
@@ -14,9 +14,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -26,9 +23,6 @@ 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;
|
||||
|
||||
@@ -21,11 +21,11 @@ gc_entity *entity, float dtime)
|
||||
struct keyboard_controller *key = GETCMP(entity, keyboard_controller);
|
||||
|
||||
con->movement_x = 0;
|
||||
con->movement_x += engine->is_keypressed(key->left_key);
|
||||
con->movement_x -= engine->is_keypressed(key->right_key);
|
||||
con->movement_x -= engine->is_keypressed(key->left_key);
|
||||
con->movement_x += engine->is_keypressed(key->right_key);
|
||||
con->movement_y = 0;
|
||||
con->movement_y += engine->is_keypressed(key->down_key);
|
||||
con->movement_y -= engine->is_keypressed(key->up_key);
|
||||
con->movement_y -= engine->is_keypressed(key->down_key);
|
||||
con->movement_y += engine->is_keypressed(key->up_key);
|
||||
(void)system;
|
||||
(void)dtime;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,23 @@
|
||||
#include "components/map_linker.h"
|
||||
#include "map_utils.h"
|
||||
#include "system.h"
|
||||
#include <math.h>
|
||||
#include <utility.h>
|
||||
|
||||
static gc_vector2i get_new_map_pos(struct map_linker *link, \
|
||||
struct controllable_component *ctl)
|
||||
{
|
||||
gc_vector2i pos = (gc_vector2i) {
|
||||
link->tile->corners[0]->x,
|
||||
link->tile->corners[0]->y
|
||||
};
|
||||
gc_vector2i move = (gc_vector2i){
|
||||
round(cos(-45) * -ctl->movement_x - sin(-45) * ctl->movement_y),
|
||||
round(sin(-45) * -ctl->movement_x + cos(-45) * ctl->movement_y),
|
||||
};
|
||||
|
||||
return (gc_vector2i_add(pos, move));
|
||||
}
|
||||
|
||||
static void update_entity(gc_engine *engine, void *system, gc_entity *entity, \
|
||||
float dtime)
|
||||
@@ -20,10 +36,7 @@ float dtime)
|
||||
gc_scene *scene = engine->scene;
|
||||
gc_list *maps = scene->get_entity_by_cmp(scene, "vertex_component");
|
||||
struct vertex_component *map;
|
||||
gc_vector2i map_pos = (gc_vector2i){
|
||||
link->tile->corners[0]->x + ctl->movement_x,
|
||||
link->tile->corners[0]->y - ctl->movement_y
|
||||
};
|
||||
gc_vector2i map_pos = get_new_map_pos(link, ctl);
|
||||
struct tile *new_tile;
|
||||
|
||||
if (!maps)
|
||||
@@ -33,6 +46,7 @@ float dtime)
|
||||
if (new_tile && !new_tile->solid && ctl->move_callback <= 0) {
|
||||
link->tile->entity = NULL;
|
||||
new_tile->entity = entity;
|
||||
engine->trigger_event(engine, "entity_moved", entity, link->tile);
|
||||
ctl->move_callback = 10;
|
||||
}
|
||||
ctl->move_callback--;
|
||||
|
||||
Reference in New Issue
Block a user