Formatted classes

This commit is contained in:
Julian Nießner
2018-05-26 11:14:12 +02:00
parent ae5fa3f2aa
commit 9ffdf66bd0
27 changed files with 574 additions and 461 deletions

View File

@@ -2,7 +2,8 @@
#include <iostream>
InputHandler::InputHandler() {
InputHandler::InputHandler()
{
W = new WCommand();
A = new ACommand();
S = new SCommand();
@@ -10,7 +11,8 @@ InputHandler::InputHandler() {
quit = new QuitCommand();
}
InputHandler::~InputHandler() {
InputHandler::~InputHandler()
{
//Free all Commands
delete W;
delete A;
@@ -19,38 +21,43 @@ InputHandler::~InputHandler() {
delete quit;
}
Command* InputHandler::handleInput(SDL_Event *event) {
if(event == NULL) {
Command *InputHandler::handleInput(SDL_Event *event)
{
if (event == NULL)
{
return NULL;
}
switch (event->type) {
case SDL_QUIT:
return quit;
switch (event->type)
{
case SDL_QUIT:
return quit;
break;
case SDL_KEYDOWN:
std::cout << "The Key " << SDL_GetKeyName(event->key.keysym.sym) << " has been pressed!" << std::endl;
return NULL;
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 SDL_KEYDOWN:
std::cout << "The Key " << SDL_GetKeyName(event->key.keysym.sym) << " has been pressed!" << std::endl;
return NULL;
case SDLK_a:
return A;
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;
case SDLK_s:
return S;
break;
default:
case SDLK_d:
return D;
break;
default:
break;
}
return NULL;
break;
default:
return NULL;
break;
}