camera.c: refactor cursor_init

So that uninitialized members are set to 0.
This commit is contained in:
Xavier Del Campo Romero 2022-06-24 17:45:14 +02:00
parent 992e7fb935
commit 8ddea5eef5
1 changed files with 15 additions and 4 deletions

View File

@ -63,10 +63,21 @@ int cursor_render(const struct cursor *const c)
void cursor_init(struct cursor *const c)
{
c->x = c->x_init = (screen_w / 2) - CAMERA_CURSOR_WIDTH;
c->y = c->y_init = (screen_h / 2) - CAMERA_CURSOR_HEIGHT;
c->screen.last_w = screen_w;
c->screen.last_h = screen_h;
const unsigned int x = (screen_w / 2) - CAMERA_CURSOR_WIDTH,
y = (screen_h / 2) - CAMERA_CURSOR_HEIGHT;
*c = (const struct cursor)
{
.x = x,
.x_init = x,
.y = y,
.y_init = y,
.screen =
{
.last_w = screen_w,
.last_h = screen_h
}
};
}
void camera_update_pos(struct camera *const cam)