Add strafing

refactor
PgSocks 2 years ago
parent be4c6f9bb5
commit 79682c1d04

@ -60,7 +60,7 @@ int main(int argc, char* argv[]) {
bool quit = false; bool quit = false;
Uint32 time = SDL_GetTicks(); Uint32 time = SDL_GetTicks();
float x = 0, y = 0; float x = 0, y = 0, z = 0;
while(!quit) { while(!quit) {
SDL_Event event; SDL_Event event;
while(SDL_PollEvent(&event)) { while(SDL_PollEvent(&event)) {
@ -68,6 +68,12 @@ int main(int argc, char* argv[]) {
case SDL_KEYUP: case SDL_KEYUP:
case SDL_KEYDOWN: case SDL_KEYDOWN:
switch(event.key.keysym.scancode) { 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_LEFT:
case SDL_SCANCODE_A: case SDL_SCANCODE_A:
x = event.type == SDL_KEYUP ? 0 : 250; x = event.type == SDL_KEYUP ? 0 : 250;
@ -98,7 +104,7 @@ int main(int argc, char* argv[]) {
{ {
time = currtime; time = currtime;
sdk_heartbeat(client); 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); set_wheel_speed(client, w1, -w2, -w3, w4);
} }
} }

Loading…
Cancel
Save