Compare commits

...

3 Commits

Author SHA1 Message Date
Ulysse Cura 0cf8b424b2 Working entity draw priority. 2026-08-11 11:22:52 +02:00
Ulysse Cura 8a087f64fa Moved components initialisation outside of other components. 2026-08-11 11:22:28 +02:00
Ulysse Cura f13ad03d6e Fixed barred door sheet. 2026-08-11 11:21:15 +02:00
8 changed files with 26 additions and 27 deletions

@ -1 +1 @@
Subproject commit 50dc383e2d027add50672b0003744b7845019780 Subproject commit ea7f7453133cb3ce231db074986820cbba86c0a6

View File

@ -4,8 +4,6 @@
###### Features ###### Features
- [ ] Work on entities draw order
- [ ] Create tilemap management and display - [ ] Create tilemap management and display
- [ ] Find tilemap building format - [ ] Find tilemap building format
- [ ] Add building support for tilemaps in asset builder - [ ] Add building support for tilemaps in asset builder
@ -26,9 +24,10 @@
### In progress ### In progress
### Done ### Done
- [x] Work on entities draw order
- [x] Make entities react to events - [x] Make entities react to events
- [x] Work on events (publish / subscribe) - [x] Work on events (publish / subscribe)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -43,14 +43,7 @@ inline int door_component_init(component_t *component)
} }
component_data->hitbox_component_data = hitbox_component->data; component_data->hitbox_component_data = hitbox_component->data;
animation_system_data_t *animation_system_data = component_data->animation_system_data;
animation_system_data->nb_frames = 8;
animation_system_data->frame_delay_ms = DOOR_DEFAULT_ANIMATION_SPEED;
if(animation_system_create_frames_clips(animation_system_data)) return EXIT_FAILURE;
component_data->topic_id = 0; component_data->topic_id = 0;
event_bus_subscribe(&game.event_bus, component_data->topic_id, door_component_callback, component->entity); event_bus_subscribe(&game.event_bus, component_data->topic_id, door_component_callback, component->entity);
component_data->state = false; component_data->state = false;

View File

@ -37,14 +37,7 @@ inline int lever_component_init(component_t *component)
} }
component_data->animation_system_data = animation_system->data; component_data->animation_system_data = animation_system->data;
animation_system_data_t *animation_system_data = component_data->animation_system_data;
animation_system_data->nb_frames = 3;
animation_system_data->frame_delay_ms = LEVER_DEFAULT_ANIMATION_SPEED;
if(animation_system_create_frames_clips(animation_system_data)) return EXIT_FAILURE;
component_data->topic_id = 0; component_data->topic_id = 0;
event_bus_subscribe(&game.event_bus, component_data->topic_id, lever_component_callback, component->entity); event_bus_subscribe(&game.event_bus, component_data->topic_id, lever_component_callback, component->entity);
component_data->state = false; component_data->state = false;

View File

@ -38,11 +38,6 @@ inline int player_system_init(component_t *component)
system_data->state = PLAYER_MOVING; system_data->state = PLAYER_MOVING;
animation_system_data_t *animation_system_data = system_data->animation_system_data;
animation_system_data->loop = true;
animation_system_data->play = true;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -32,8 +32,10 @@ inline int sprite_component_init(component_t *component)
inline int sprite_component_update(component_t *component) inline int sprite_component_update(component_t *component)
{ {
sprite_component_data_t *component_data = component->data; sprite_component_data_t *component_data = component->data;
transform_component_data_t *transform_component_data = component_data->transform_component_data;
component_data->dst_rect = component_data->transform_component_data->bounds; component_data->dst_rect = transform_component_data->bounds;
component->entity->draw_priority = transform_component_data->bounds.y + transform_component_data->bounds.h;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -41,7 +41,13 @@ int game_init(void)
}; };
if(!entity_new_component(player_entity, SPRITE_COMPONENT)) return EXIT_FAILURE; if(!entity_new_component(player_entity, SPRITE_COMPONENT)) return EXIT_FAILURE;
if(!entity_new_component(player_entity, ANIMATION_SYSTEM)) return EXIT_FAILURE;
component = entity_new_component(player_entity, ANIMATION_SYSTEM);
if(!component) return EXIT_FAILURE;
((animation_system_data_t *)component->data)->loop = true;
((animation_system_data_t *)component->data)->play = true;
component = entity_new_component(player_entity, HITBOX_COMPONENT); component = entity_new_component(player_entity, HITBOX_COMPONENT);
if(!component) return EXIT_FAILURE; if(!component) return EXIT_FAILURE;
@ -56,6 +62,7 @@ int game_init(void)
}; };
if(!entity_new_component(player_entity, PHYSICS_SYSTEM)) return EXIT_FAILURE; if(!entity_new_component(player_entity, PHYSICS_SYSTEM)) return EXIT_FAILURE;
if(!entity_new_component(player_entity, PLAYER_SYSTEM)) return EXIT_FAILURE; if(!entity_new_component(player_entity, PLAYER_SYSTEM)) return EXIT_FAILURE;
/* ======== Lever ========*/ /* ======== Lever ========*/
@ -77,7 +84,12 @@ int game_init(void)
if(sprite_component_set_texture(component->data, "lever_sheet")) return EXIT_FAILURE; if(sprite_component_set_texture(component->data, "lever_sheet")) return EXIT_FAILURE;
if(!entity_new_component(lever_entity, ANIMATION_SYSTEM)) return EXIT_FAILURE; component = entity_new_component(lever_entity, ANIMATION_SYSTEM);
if(!component) return EXIT_FAILURE;
((animation_system_data_t *)component->data)->nb_frames = 3;
((animation_system_data_t *)component->data)->frame_delay_ms = LEVER_DEFAULT_ANIMATION_SPEED;
if(animation_system_create_frames_clips(component->data)) return EXIT_FAILURE;
component = entity_new_component(lever_entity, HITBOX_COMPONENT); component = entity_new_component(lever_entity, HITBOX_COMPONENT);
if(!component) return EXIT_FAILURE; if(!component) return EXIT_FAILURE;
@ -126,7 +138,12 @@ int game_init(void)
if(sprite_component_set_texture(component->data, "barred_door_sheet")) return EXIT_FAILURE; if(sprite_component_set_texture(component->data, "barred_door_sheet")) return EXIT_FAILURE;
if(!entity_new_component(door_entity, ANIMATION_SYSTEM)) return EXIT_FAILURE; component = entity_new_component(door_entity, ANIMATION_SYSTEM);
if(!component) return EXIT_FAILURE;
((animation_system_data_t *)component->data)->nb_frames = 8;
((animation_system_data_t *)component->data)->frame_delay_ms = DOOR_DEFAULT_ANIMATION_SPEED;
if(animation_system_create_frames_clips(component->data)) return EXIT_FAILURE;
component = entity_new_component(door_entity, HITBOX_COMPONENT); component = entity_new_component(door_entity, HITBOX_COMPONENT);
if(!component) return EXIT_FAILURE; if(!component) return EXIT_FAILURE;