aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-06-24 17:45:14 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-06-24 17:45:14 +0200
commit8ddea5eef59dbc124f914560af61b78867671482 (patch)
treeea3fa1203ad02ae23fc383642f5e8b423150ed04 /src
parent992e7fb9358a0d0a5d99ba119cf584477bda8d72 (diff)
downloadrts-8ddea5eef59dbc124f914560af61b78867671482.tar.gz
camera.c: refactor cursor_init
So that uninitialized members are set to 0.
Diffstat (limited to 'src')
-rw-r--r--src/camera/src/camera.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/camera/src/camera.c b/src/camera/src/camera.c
index e8f9cd5..0c4ffd1 100644
--- a/src/camera/src/camera.c
+++ b/src/camera/src/camera.c
@@ -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)