rendered paste bodyvoid Game::controlKeys(Player *p)
{
SDL_EnableUNICODE(1);
if((this->checkKey(SDLK_LEFT)))
{
p->move(DIR_LEFT);
}
else if((this->checkKey(SDLK_RIGHT)))
{
p->move(DIR_RIGHT);
}
else if((this->checkKey(SDLK_UP)))
{
p->move(DIR_UP);
}
else if((this->checkKey(SDLK_DOWN)))
{
p->move(DIR_DOWN);
}
// Deleting :)
if(this->checkKey(SDLK_BACKSPACE))
this->writeString = trim(this->writeString, 1);
SDL_PollEvent (&this->event);
switch (this->event.type)
{
case SDL_KEYDOWN:
{
if(this->event.type > 0 && !this->checkKey(SDLK_BACKSPACE) &&
!this->checkKey(SDLK_RETURN) && !this->checkKey(SDLK_CAPSLOCK) )
this->writeString += event.key.keysym.unicode;
// Trigger FPS showing
if(event.key.keysym.sym == SDLK_F1)
{
(this->showFPS) ? this->showFPS = false : this->showFPS = true;
}
break;
}
case SDL_QUIT:
{
this->running = false;
break;
}
case SDLK_LEFT:
{
this->running = false;
break;
}
case SDL_VIDEORESIZE:
{
drawengine->ResizeWindow(event.resize.w, event.resize.h, SDL_RESIZABLE | SDL_OPENGL);
break;
}
default: break;
}
}