From 79682c1d04e99b23964419d73c389a526cee6480 Mon Sep 17 00:00:00 2001 From: PgSocks Date: Tue, 10 Jan 2023 13:32:29 -0600 Subject: [PATCH] Add strafing --- src/sdl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sdl.c b/src/sdl.c index 42555f9..2b855fc 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) { bool quit = false; Uint32 time = SDL_GetTicks(); - float x = 0, y = 0; + float x = 0, y = 0, z = 0; while(!quit) { SDL_Event event; while(SDL_PollEvent(&event)) { @@ -68,6 +68,12 @@ int main(int argc, char* argv[]) { case SDL_KEYUP: case SDL_KEYDOWN: switch(event.key.keysym.scancode) { + case SDL_SCANCODE_Q: + z = event.type == SDL_KEYUP ? 0 : 250; + break; + case SDL_SCANCODE_E: + z = event.type == SDL_KEYUP ? 0 : -250; + break; case SDL_SCANCODE_LEFT: case SDL_SCANCODE_A: x = event.type == SDL_KEYUP ? 0 : 250; @@ -98,7 +104,7 @@ int main(int argc, char* argv[]) { { time = currtime; sdk_heartbeat(client); - float w1 = y + x, w2 = y - x, w3 = y - x, w4 = y + x; + float w1 = y + x + z, w2 = y - x -z, w3 = y + x -z, w4 = y - x + z; set_wheel_speed(client, w1, -w2, -w3, w4); } }