From df696d9f99272843dc212aad7c10329f9e6e2d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Wed, 12 Sep 2018 12:44:39 +0200 Subject: [PATCH] Add shear --- testSDL.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/testSDL.c b/testSDL.c index baa9af9..dff9094 100644 --- a/testSDL.c +++ b/testSDL.c @@ -29,13 +29,15 @@ #define max(a,b) ((a) > (b) ? (a) : (b)) -#define KEYS 6 +#define KEYS 8 #define KEY_UP 0 #define KEY_RIGHT 1 #define KEY_DOWN 2 #define KEY_LEFT 3 #define KEY_Q 4 #define KEY_W 5 +#define KEY_A 6 +#define KEY_S 7 int keys[KEYS]; @@ -963,6 +965,8 @@ int main() case SDL_SCANCODE_LEFT: keyIndex = KEY_LEFT; break; case SDL_SCANCODE_Q: keyIndex = KEY_Q; break; case SDL_SCANCODE_W: keyIndex = KEY_W; break; + case SDL_SCANCODE_A: keyIndex = KEY_A; break; + case SDL_SCANCODE_S: keyIndex = KEY_S; break; default: break; } break; @@ -1008,6 +1012,13 @@ int main() else if (keys[KEY_LEFT]) camera.direction -= step2; + const int shearAdd = 10; + + if (keys[KEY_A]) + camera.shear = camera.shear + shearAdd <= SCREEN_HEIGHT ? camera.shear + shearAdd : SCREEN_HEIGHT; + else if (keys[KEY_S]) + camera.shear = camera.shear - shearAdd >= -1 * SCREEN_HEIGHT ? camera.shear - shearAdd : -1 * SCREEN_HEIGHT; + SDL_RenderClear(renderer); SDL_RenderCopy(renderer,texture,NULL,NULL); SDL_RenderPresent(renderer);