From 0f9e2d89589f05847fb7dc808da1594f0961b5b4 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 12 Jun 2022 22:34:23 +0200 Subject: Split peripheral-related logic into its own component This has several advantages: - `camera` no longer needs to define public functions for each peripheral type. - Peripheral-related is now no longer tighly coupled to human_player, so peripheral logic can be reused elsewhere e.g.: on menus. - Makes camera_update_touch consistent compared to equivalent functions, since now `pan` has now been moved to `camera` (as it should be). --- src/camera/inc/camera.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/camera/inc') diff --git a/src/camera/inc/camera.h b/src/camera/inc/camera.h index 93ad740..8356bd8 100644 --- a/src/camera/inc/camera.h +++ b/src/camera/inc/camera.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -15,6 +16,7 @@ struct camera { int x, y, x_speed, y_speed; unsigned int xt, yt; + bool pan; struct cursor { @@ -33,9 +35,7 @@ struct camera extern struct sprite cursor_sprite; -void camera_update_pad(struct camera *cam, const struct pad *p); -void camera_update_mouse(struct camera *cam, const struct mouse *m); -bool camera_update_touch(struct camera *cam, const struct mouse *m); +void camera_update(struct camera *cam, const union peripheral *p); bool camera_translate(const struct camera *cam, const struct util_rect *dim, short *x, short *y); void cursor_init(struct cursor *c); bool cursor_collision(const struct camera *cam, const struct util_rect *d); -- cgit v1.2.3