Some test inputs and commentarys

This commit is contained in:
Julian Nießner
2018-05-25 12:13:06 +02:00
parent 3169790299
commit ae5fa3f2aa
14 changed files with 108 additions and 33 deletions

View File

@@ -1,14 +1,22 @@
#include "InputHandler.h"
#include "../DesktopLauncher.h"
#include <iostream>
InputHandler::InputHandler() {
W = new WCommand();
A = new ACommand();
S = new SCommand();
D = new DCommand();
quit = new QuitCommand();
}
InputHandler::~InputHandler() {
//Free all Commands
delete W;
delete A;
delete S;
delete D;
delete quit;
}
Command* InputHandler::handleInput(SDL_Event *event) {
@@ -17,8 +25,7 @@ Command* InputHandler::handleInput(SDL_Event *event) {
}
switch (event->type) {
case SDL_QUIT:
Game::exit();
return NULL;
return quit;
break;
case SDL_KEYDOWN:
std::cout << "The Key " << SDL_GetKeyName(event->key.keysym.sym) << " has been pressed!" << std::endl;
@@ -26,6 +33,21 @@ Command* InputHandler::handleInput(SDL_Event *event) {
break;
case SDL_KEYUP:
std::cout << "The Key " << SDL_GetKeyName(event->key.keysym.sym) << " has been released!" << std::endl;
switch(event->key.keysym.sym) {
case SDLK_w:
return W;
break;
case SDLK_a:
return A;
break;
case SDLK_s:
return S;
break;
case SDLK_d:
return D;
break;
default: break;
}
return NULL;
break;
default: