From ff2c529dda20dba1ea7ef21f46703d59fb49178b Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Thu, 21 Sep 2023 21:28:50 -0600 Subject: Better looking gyro --- src/entities/antifaShip.c | 7 +++++++ src/entities/antifaShip.h | 1 + 2 files changed, 8 insertions(+) (limited to 'src/entities') diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index fb307fb..bd64545 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -29,6 +29,7 @@ void initAntifaShip(Entity * entity, Game * game) { AntifaShip * data = (AntifaShip*)entity->data; data->lastMouse = GetMousePosition(); data->forwardSpeed = 0.0; + data->shouldInitMousePosition = true; } void closeAntifaShip(Entity * entity) { @@ -77,6 +78,12 @@ void controlAntifaShipJoystick(Game * game, Entity * entity) { void controlAntifaShipKeyboardAndMouse(Game * game, Entity * entity) { AntifaShip * data = (AntifaShip*)entity->data; + // Resets mouse on init. + if (data->shouldInitMousePosition) { + data->shouldInitMousePosition = false; + SetMousePosition(0, 0); + } + // Get mouse values. Vector2 mouse = GetMousePosition(); float speed = GetMouseWheelMove(); diff --git a/src/entities/antifaShip.h b/src/entities/antifaShip.h index 06ef094..e9c78bd 100644 --- a/src/entities/antifaShip.h +++ b/src/entities/antifaShip.h @@ -9,6 +9,7 @@ typedef struct AntifaShip { Vector2 lastMouse; float forwardSpeed; + bool shouldInitMousePosition; } AntifaShip; void initAntifaShip(Entity * entity, Game * game); -- cgit v1.2.3