Reorganised headers to match design choices and component creation order for correct update order.
This commit is contained in:
parent
ce8c50f96c
commit
46682c00e2
|
|
@ -2,10 +2,10 @@
|
||||||
#define COMPONENTS_H
|
#define COMPONENTS_H
|
||||||
|
|
||||||
#include "transform_component.h"
|
#include "transform_component.h"
|
||||||
#include "hitbox_component.h"
|
|
||||||
#include "physics_system.h"
|
|
||||||
#include "sprite_component.h"
|
#include "sprite_component.h"
|
||||||
#include "animation_system.h"
|
#include "animation_system.h"
|
||||||
|
#include "hitbox_component.h"
|
||||||
|
#include "physics_system.h"
|
||||||
#include "player_system.h"
|
#include "player_system.h"
|
||||||
// Add new components header file here
|
// Add new components header file here
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "ecs.h"
|
#include "ecs.h"
|
||||||
#include "transform_component.h"
|
#include "transform_component.h"
|
||||||
#include "vector2d.h"
|
#include "vector2d.h"
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
typedef struct hitbox_component_data_t {
|
typedef struct hitbox_component_data_t {
|
||||||
transform_component_data_t *transform_component_data;
|
transform_component_data_t *transform_component_data;
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
#define PLAYER_SYSTEM_H
|
#define PLAYER_SYSTEM_H
|
||||||
|
|
||||||
#include "ecs.h"
|
#include "ecs.h"
|
||||||
#include "physics_system.h"
|
|
||||||
#include "sprite_component.h"
|
#include "sprite_component.h"
|
||||||
#include "animation_system.h"
|
#include "animation_system.h"
|
||||||
|
#include "physics_system.h"
|
||||||
|
|
||||||
#define PLAYER_DEFAULT_WALK_SPEED 60.0f // px / s
|
#define PLAYER_DEFAULT_WALK_SPEED 60.0f // px / s
|
||||||
#define PLAYER_DEFAULT_RUN_SPEED 100.0f // px / s
|
#define PLAYER_DEFAULT_RUN_SPEED 100.0f // px / s
|
||||||
|
|
@ -24,9 +24,9 @@ typedef enum player_state_t {
|
||||||
} player_state_t;
|
} player_state_t;
|
||||||
|
|
||||||
typedef struct player_system_data_t {
|
typedef struct player_system_data_t {
|
||||||
physics_system_data_t *physics_system_data;
|
|
||||||
sprite_component_data_t *sprite_component_data;
|
sprite_component_data_t *sprite_component_data;
|
||||||
animation_system_data_t *animation_system_data;
|
animation_system_data_t *animation_system_data;
|
||||||
|
physics_system_data_t *physics_system_data;
|
||||||
|
|
||||||
player_state_t state;
|
player_state_t state;
|
||||||
player_state_t last_state;
|
player_state_t last_state;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "ecs.h"
|
#include "ecs.h"
|
||||||
#include "vector2d.h"
|
#include "vector2d.h"
|
||||||
|
#include "errors.h"
|
||||||
|
|
||||||
typedef struct transform_component_data_t {
|
typedef struct transform_component_data_t {
|
||||||
frect_t bounds;
|
frect_t bounds;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include "hitbox_component.h"
|
#include "hitbox_component.h"
|
||||||
|
|
||||||
|
#include "game.h"
|
||||||
#include "transform_component.h"
|
#include "transform_component.h"
|
||||||
#include "memory_alloc.h"
|
#include "memory_alloc.h"
|
||||||
#include "game.h"
|
|
||||||
|
|
||||||
// Args : frect_t bounds, double speed
|
// Args : frect_t bounds, double speed
|
||||||
int hitbox_component_init(component_t *component)
|
int hitbox_component_init(component_t *component)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#include "physics_system.h"
|
#include "physics_system.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include "game.h"
|
||||||
#include "vector2d.h"
|
#include "vector2d.h"
|
||||||
#include "memory_alloc.h"
|
#include "memory_alloc.h"
|
||||||
#include "game.h"
|
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
|
||||||
// Args : frect_t bounds, double speed
|
// Args : frect_t bounds, double speed
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include "player_system.h"
|
#include "player_system.h"
|
||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "memory_alloc.h"
|
|
||||||
#include "animation_system.h"
|
#include "animation_system.h"
|
||||||
#include "sprite_component.h"
|
#include "sprite_component.h"
|
||||||
#include "physics_system.h"
|
#include "physics_system.h"
|
||||||
|
#include "memory_alloc.h"
|
||||||
|
|
||||||
// No args
|
// No args
|
||||||
inline int player_system_init(component_t *component)
|
inline int player_system_init(component_t *component)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include "sprite_component.h"
|
#include "sprite_component.h"
|
||||||
|
|
||||||
#include "memory_alloc.h"
|
|
||||||
#include "display.h"
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include "display.h"
|
||||||
|
#include "memory_alloc.h"
|
||||||
|
|
||||||
// Arg : const char *name
|
// Arg : const char *name
|
||||||
inline int sprite_component_init(component_t *component)
|
inline int sprite_component_init(component_t *component)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "transform_component.h"
|
#include "transform_component.h"
|
||||||
|
|
||||||
#include "memory_alloc.h"
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include "memory_alloc.h"
|
||||||
|
|
||||||
// Args : frect_t bounds, double speed
|
// Args : frect_t bounds, double speed
|
||||||
int transform_component_init(component_t *component)
|
int transform_component_init(component_t *component)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ int game_init(void)
|
||||||
.h = 32.0f
|
.h = 32.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(!entity_new_component(player, SPRITE_COMPONENT)) return EXIT_FAILURE;
|
||||||
|
if(!entity_new_component(player, ANIMATION_SYSTEM)) return EXIT_FAILURE;
|
||||||
component = entity_new_component(player, HITBOX_COMPONENT);
|
component = entity_new_component(player, HITBOX_COMPONENT);
|
||||||
if(!component) return EXIT_FAILURE;
|
if(!component) return EXIT_FAILURE;
|
||||||
|
|
||||||
|
|
@ -50,8 +52,6 @@ int game_init(void)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!entity_new_component(player, PHYSICS_SYSTEM)) return EXIT_FAILURE;
|
if(!entity_new_component(player, PHYSICS_SYSTEM)) return EXIT_FAILURE;
|
||||||
if(!entity_new_component(player, SPRITE_COMPONENT)) return EXIT_FAILURE;
|
|
||||||
if(!entity_new_component(player, ANIMATION_SYSTEM)) return EXIT_FAILURE;
|
|
||||||
if(!entity_new_component(player, PLAYER_SYSTEM)) return EXIT_FAILURE;
|
if(!entity_new_component(player, PLAYER_SYSTEM)) return EXIT_FAILURE;
|
||||||
|
|
||||||
/* ======== Test entity ======== */
|
/* ======== Test entity ======== */
|
||||||
|
|
@ -68,6 +68,7 @@ int game_init(void)
|
||||||
.h = 32.0f
|
.h = 32.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(!entity_new_component(entity, SPRITE_COMPONENT)) return EXIT_FAILURE;
|
||||||
component = entity_new_component(entity, HITBOX_COMPONENT);
|
component = entity_new_component(entity, HITBOX_COMPONENT);
|
||||||
if(!component) return EXIT_FAILURE;
|
if(!component) return EXIT_FAILURE;
|
||||||
|
|
||||||
|
|
@ -81,8 +82,6 @@ int game_init(void)
|
||||||
.y = 2.0f / 3.0f
|
.y = 2.0f / 3.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!entity_new_component(entity, SPRITE_COMPONENT)) return EXIT_FAILURE;
|
|
||||||
|
|
||||||
game.is_running = true;
|
game.is_running = true;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue