Compare commits

...

3 Commits

Author SHA1 Message Date
Ulysse Cura b63a67eb84 Add lerp function. 2026-08-04 19:48:11 +02:00
Ulysse Cura 344664f537 Re fixing components update order :'). 2026-08-04 19:47:59 +02:00
Ulysse Cura e6d363c0b2 Changing texture display dst rect to frect. 2026-08-04 19:47:42 +02:00
5 changed files with 13 additions and 7 deletions

View File

@ -62,7 +62,7 @@ inline int display_init(void)
return EXIT_FAILURE;
}
if(!SDL_SetDefaultTextureScaleMode(renderer, SDL_SCALEMODE_PIXELART))
if(!SDL_SetDefaultTextureScaleMode(renderer, SDL_SCALEMODE_NEAREST))
{
error_printf("Failed to set default texture scale mode : %s", SDL_GetError());
return EXIT_FAILURE;
@ -133,13 +133,12 @@ inline void display_update(void)
#endif // DEBUG >= 1
}
int display_draw_texture(texture_t *texture, rect_t *src_rect, rect_t *dst_rect, bool flip)
int display_draw_texture(texture_t *texture, rect_t *src_rect, frect_t *dst_frect, bool flip)
{
frect_t src_frect, dst_frect;
frect_t src_frect;
rect_to_frect(src_rect, &src_frect);
rect_to_frect(dst_rect, &dst_frect);
if(!SDL_RenderTextureRotated(renderer, texture, &src_frect, &dst_frect, 0, NULL, flip))
if(!SDL_RenderTextureRotated(renderer, texture, &src_frect, dst_frect, 0, NULL, flip))
{
error_printf("Failed to copy texture to renderer : %s", SDL_GetError());
return EXIT_FAILURE;

View File

@ -91,7 +91,7 @@ component_t *entity_new_component(entity_t *entity, component_type_t component_t
if(component->component_init(component)) return NULL;
if(linked_list_push_back(&entity->components, component_elem)) return NULL;
if(linked_list_push_front(&entity->components, component_elem)) return NULL;
return component;
}

View File

@ -27,7 +27,7 @@ void display_exit(void);
int display_clear(void);
void display_update(void);
int display_draw_texture(texture_t *texture, rect_t *src_rect, rect_t *dst_rect, bool flip);
int display_draw_texture(texture_t *texture, rect_t *src_rect, frect_t *dst_frect, bool flip);
int display_draw_frect(frect_t *frect, unsigned int r, unsigned int g, unsigned int b, unsigned int a);
#endif // DISPLAY_H

View File

@ -131,4 +131,6 @@ void frect_to_rect(const frect_t *frect, rect_t *rect);
*/
#define intersect_frect(A, B, result) SDL_IntersectFRect(A, B, result)
float lerp(float a, float b, float t);
#endif // VECTOR2D_H

View File

@ -15,3 +15,8 @@ void frect_to_rect(const frect_t *frect, rect_t *rect)
rect->w = (int)frect->w;
rect->h = (int)frect->h;
}
float lerp(float a, float b, float t)
{
return a * (1 - t) + b * t;
}