From f9a32bdb72c7a1f8dde51aee7e3053f8f51f7e54 Mon Sep 17 00:00:00 2001 From: zv0n Date: Sat, 24 Sep 2022 20:44:52 +0200 Subject: [PATCH] Mario: add arrow key controls --- mario/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mario/main.cpp b/mario/main.cpp index 8ccda9e..20fce13 100644 --- a/mario/main.cpp +++ b/mario/main.cpp @@ -1,4 +1,5 @@ #include "../sdlpp/sdlpp.hpp" +#include "SDL2/SDL_keycode.h" #include "sprites.hpp" #include #ifdef _WIN32 @@ -44,16 +45,20 @@ std::mutex gamescene_mutex; void handleKeyDown(SDL_Keycode key, SDLPP::Scene &scene) { switch (key) { case SDLK_a: + case SDLK_LEFT: mario->walkLeft(); break; case SDLK_d: + case SDLK_RIGHT: mario->walkRight(); break; case SDLK_SPACE: case SDLK_w: + case SDLK_UP: mario->jump(); break; case SDLK_s: + case SDLK_DOWN: break; case SDLK_r: scene.getRenderer().setRenderColiders( @@ -76,13 +81,16 @@ void handleKeyUp(SDL_Keycode key) { createGameMainMenuScene(renderer, false, true, true)); } break; case SDLK_a: + case SDLK_LEFT: mario->walkRight(); break; case SDLK_d: + case SDLK_RIGHT: mario->walkLeft(); break; case SDLK_SPACE: case SDLK_w: + case SDLK_UP: mario->stopJump(); default: break;