From 41d2578d3401e38fa8600a533ad5998dc39e7be5 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sat, 21 May 2022 21:36:37 +0200 Subject: add move sideways capability --- src/keyboard.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/keyboard.cpp') diff --git a/src/keyboard.cpp b/src/keyboard.cpp index 1eff1d1..8f5d81c 100644 --- a/src/keyboard.cpp +++ b/src/keyboard.cpp @@ -2,13 +2,18 @@ Keyboard::Keyboard(){ nop = new Nop; - pressedDown = new KeyboardDownPressed; - releasedDown = new KeyboardDownReleased; + + pressedDown = new KeyboardDownPressed; + releasedDown = new KeyboardDownReleased; + pressedLeft = new KeyboardLeftPressed; + pressedRight = new KeyboardRightPressed; } Keyboard::~Keyboard(){ delete nop; delete pressedDown; delete releasedDown; + delete pressedLeft; + delete pressedRight; } Command* Keyboard::handleEvent( SDL_Event e ){ @@ -26,6 +31,10 @@ Command* Keyboard::pressed( SDL_Keycode k, Uint16 mod ){ switch(k){ case SDLK_DOWN: return pressedDown; + case SDLK_LEFT: + return pressedLeft; + case SDLK_RIGHT: + return pressedRight; default: return nop; } -- cgit v1.2.3