Compare commits

..

2 Commits

Author SHA1 Message Date
Ulysse Cura 60b58036a9 Fixed camera follow offset to int. 2026-09-02 18:37:59 +02:00
Ulysse Cura 365df6a0c8 Fixed til accesse variables types. 2026-09-02 18:35:06 +02:00
3 changed files with 13 additions and 13 deletions

View File

@ -6,16 +6,16 @@
void camera_init(void)
{
game.camera.view_rect = (rect_t) {
.x = 0.0f,
.y = 0.0f,
.x = 0,
.y = 0,
.w = DISPLAY_WIDTH / 2,
.h = DISPLAY_HEIGHT / 2
};
game.camera.tracking_pos = NULL;
game.camera.tracking_center_offset = (fvector2d_t) {
.x = 0.0f,
.y = 0.0f
game.camera.tracking_center_offset = (vector2d_t) {
.x = 0,
.y = 0
};
}

View File

@ -6,7 +6,7 @@
typedef struct camera_t {
rect_t view_rect;
fvector2d_t *tracking_pos;
fvector2d_t tracking_center_offset;
vector2d_t tracking_center_offset;
} camera_t;
void camera_init(void);

View File

@ -401,7 +401,7 @@ int map_remove_entities(map_t *map)
}
static inline int draw_tile(uint32_t tile_x, uint32_t tile_y, uint16_t tile_id)
static inline int draw_tile(uint16_t tile_x, uint16_t tile_y, uint16_t tile_id)
{
if(!tile_id) return EXIT_SUCCESS;
@ -426,24 +426,24 @@ static inline int draw_tile(uint32_t tile_x, uint32_t tile_y, uint16_t tile_id)
int map_display_background(void)
{
uint32_t left_tile = 0;
uint16_t left_tile = 0;
if(game.camera.view_rect.x / TILE_SIZE > 0)
left_tile = game.camera.view_rect.x / TILE_SIZE;
uint32_t right_tile = game.map->width;
uint16_t right_tile = game.map->width;
if((game.camera.view_rect.x + game.camera.view_rect.w) / TILE_SIZE + 1 < game.map->width)
right_tile = (game.camera.view_rect.x + game.camera.view_rect.w) / TILE_SIZE + 1;
uint32_t top_tile = 0;
uint16_t top_tile = 0;
if(game.camera.view_rect.y / TILE_SIZE > 0)
top_tile = game.camera.view_rect.y / TILE_SIZE;
uint32_t bottom_tile = game.map->height;
uint16_t bottom_tile = game.map->height;
if((game.camera.view_rect.y + game.camera.view_rect.h) / TILE_SIZE + 1 < game.map->height)
bottom_tile = (game.camera.view_rect.y + game.camera.view_rect.h) / TILE_SIZE + 1;
for(uint32_t tile_y = top_tile; tile_y < bottom_tile; tile_y++)
for(uint32_t tile_x = left_tile; tile_x < right_tile; tile_x++)
for(uint16_t tile_y = top_tile; tile_y < bottom_tile; tile_y++)
for(uint16_t tile_x = left_tile; tile_x < right_tile; tile_x++)
{
elem_t *backgroundlayer_elem = game.map->backgroundlayers.first;