Using the asset manager to load and store any type of assets.
This commit is contained in:
parent
d070dc8566
commit
7dd5ea4f72
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "ecs.h"
|
#include "ecs.h"
|
||||||
#include "transform_component.h"
|
#include "transform_component.h"
|
||||||
#include "texture_manager.h"
|
#include "asset_manager.h"
|
||||||
|
|
||||||
typedef struct sprite_component_data_t {
|
typedef struct sprite_component_data_t {
|
||||||
transform_component_data_t *transform_component_data;
|
transform_component_data_t *transform_component_data;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ inline void sprite_component_update(component_t *component)
|
||||||
inline void sprite_component_draw(component_t *component)
|
inline void sprite_component_draw(component_t *component)
|
||||||
{
|
{
|
||||||
sprite_component_data_t *component_data = component->component_data;
|
sprite_component_data_t *component_data = component->component_data;
|
||||||
draw_texture(component_data->texture, &component_data->src_rect, &component_data->dst_rect, component_data->flip);
|
asset_manager_draw_texture(component_data->texture, &component_data->src_rect, &component_data->dst_rect, component_data->flip);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sprite_component_destroy(component_t *component)
|
inline void sprite_component_destroy(component_t *component)
|
||||||
|
|
@ -37,5 +37,5 @@ inline void sprite_component_destroy(component_t *component)
|
||||||
|
|
||||||
inline void sprite_component_set_texture(sprite_component_data_t *component_data, const char *name)
|
inline void sprite_component_set_texture(sprite_component_data_t *component_data, const char *name)
|
||||||
{
|
{
|
||||||
component_data->texture = texture_manager_get_texture(&game.texture_manager, name);
|
component_data->texture = asset_manager_get_texture(&game.asset_manager, name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,8 @@
|
||||||
void game_init(void)
|
void game_init(void)
|
||||||
{
|
{
|
||||||
display_init();
|
display_init();
|
||||||
asset_manager_init();
|
|
||||||
|
|
||||||
texture_manager_init(&game.texture_manager);
|
asset_manager_init(&game.asset_manager);
|
||||||
entity_manager_init(&game.entity_manager);
|
entity_manager_init(&game.entity_manager);
|
||||||
|
|
||||||
entity_t *player = create_entity(0);
|
entity_t *player = create_entity(0);
|
||||||
|
|
@ -69,9 +68,8 @@ void game_render(void)
|
||||||
|
|
||||||
void game_exit(void)
|
void game_exit(void)
|
||||||
{
|
{
|
||||||
|
asset_manager_exit(&game.asset_manager);
|
||||||
entity_manager_clear(&game.entity_manager);
|
entity_manager_clear(&game.entity_manager);
|
||||||
texture_manager_clear(&game.texture_manager);
|
|
||||||
|
|
||||||
asset_manager_exit();
|
|
||||||
display_exit();
|
display_exit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
#include "texture_manager.h"
|
#include "asset_manager.h"
|
||||||
#include "ecs.h"
|
#include "ecs.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
*/
|
*/
|
||||||
typedef struct game_t {
|
typedef struct game_t {
|
||||||
events_t events;
|
events_t events;
|
||||||
texture_manager_t texture_manager;
|
asset_manager_t asset_manager;
|
||||||
entity_manager_t entity_manager;
|
entity_manager_t entity_manager;
|
||||||
|
|
||||||
bool is_running;
|
bool is_running;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue