tunnel-runner

Pseudo 3D tunnel effect.
git clone git://git.amin.space/tunnel-runner.git
Log | Files | Refs | README | LICENSE

commit ccaaa08a0dcf0178663d99f40a2bcd044d17e97d
parent 9842b7c6528e5168b189a4719959462d57889f78
Author: amin <dev@aminmesbah.com>
Date:   Sat, 12 Nov 2016 20:14:02 +0000

Handle keyboard input.

FossilOrigin-Name: 4070f52f867a4c245a21206f0114d801d504e91d3b1b295da68cb5391cfcc5df
Diffstat:
Msdl_tunnel_flyer.cpp | 38++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+), 0 deletions(-)

diff --git a/sdl_tunnel_flyer.cpp b/sdl_tunnel_flyer.cpp @@ -23,6 +23,7 @@ typedef uint64_t uint64; #define BYTES_PER_PIXEL 4 #define MAX_CONTROLLERS 4 +#define MOVEMENT_SPEED 5 struct SDLOffscreenBuffer @@ -277,6 +278,43 @@ int main(void) } } + SDL_PumpEvents(); + const uint8 *keystate = SDL_GetKeyboardState(0); + + if (keystate[SDL_SCANCODE_A]) + { + x_offset -= MOVEMENT_SPEED; + } + if (keystate[SDL_SCANCODE_D]) + { + x_offset += MOVEMENT_SPEED; + } + if (keystate[SDL_SCANCODE_W]) + { + y_offset -= MOVEMENT_SPEED; + } + if (keystate[SDL_SCANCODE_S]) + { + y_offset += MOVEMENT_SPEED; + } + if (keystate[SDL_SCANCODE_LEFT]) + { + x_offset --; + } + if (keystate[SDL_SCANCODE_RIGHT]) + { + x_offset ++; + } + if (keystate[SDL_SCANCODE_UP]) + { + y_offset --; + } + if (keystate[SDL_SCANCODE_DOWN]) + { + y_offset ++; + } + + for (int controller_index = 0; controller_index < MAX_CONTROLLERS; ++controller_index) { if (SDL_GameControllerGetAttached(controller_handles[controller_index]))