Working entity draw priority.

This commit is contained in:
Ulysse Cura 2026-08-11 11:22:52 +02:00
parent 8a087f64fa
commit 0cf8b424b2
4 changed files with 26 additions and 8 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)

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;