2014-08-12 22:15:26 +02:00
|
|
|
#include "State.hpp"
|
2014-09-16 20:22:43 +02:00
|
|
|
#include "RWGame.hpp"
|
2014-08-12 22:15:26 +02:00
|
|
|
|
|
|
|
// This serves as the "initial" camera position.
|
|
|
|
ViewCamera defaultView({-250.f, -550.f, 75.f}, glm::angleAxis(glm::radians(5.f), glm::vec3(0.f, 1.f, 0.f)));
|
|
|
|
|
2016-06-22 12:29:39 +02:00
|
|
|
|
|
|
|
void State::handleEvent(const SDL_Event& e)
|
|
|
|
{
|
|
|
|
auto m = getCurrentMenu();
|
|
|
|
if(!m) return;
|
|
|
|
|
|
|
|
switch(e.type) {
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
if (e.button.button == SDL_BUTTON_LEFT)
|
|
|
|
m->click(e.button.x, e.button.y);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_MOUSEMOTION:
|
|
|
|
m->hover(e.motion.x, e.motion.y);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_KEYDOWN:
|
|
|
|
switch (e.key.keysym.sym) {
|
|
|
|
case SDLK_UP:
|
|
|
|
m->move(-1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDLK_DOWN:
|
|
|
|
m->move(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDLK_RETURN:
|
|
|
|
m->activate();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-12 22:15:26 +02:00
|
|
|
const ViewCamera& State::getCamera()
|
|
|
|
{
|
|
|
|
return defaultView;
|
|
|
|
}
|
2014-09-16 20:22:43 +02:00
|
|
|
|
2015-04-03 16:38:24 +02:00
|
|
|
bool State::shouldWorldUpdate()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-16 20:22:43 +02:00
|
|
|
GameWorld* State::getWorld()
|
|
|
|
{
|
|
|
|
return game->getWorld();
|
|
|
|
}
|
|
|
|
|
2016-06-22 12:29:39 +02:00
|
|
|
GameWindow& State::getWindow()
|
2014-09-16 20:22:43 +02:00
|
|
|
{
|
|
|
|
return game->getWindow();
|
|
|
|
}
|