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.
|
2016-09-09 22:13:20 +02:00
|
|
|
ViewCamera defaultView({-250.f, -550.f, 75.f},
|
|
|
|
glm::angleAxis(glm::radians(5.f),
|
|
|
|
glm::vec3(0.f, 1.f, 0.f)));
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2016-06-22 12:29:39 +02:00
|
|
|
}
|
|
|
|
|
2016-11-30 00:28:53 +01:00
|
|
|
const ViewCamera& State::getCamera(float alpha) {
|
2016-09-09 22:13:20 +02:00
|
|
|
return defaultView;
|
2014-08-12 22:15:26 +02:00
|
|
|
}
|
2014-09-16 20:22:43 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
bool State::shouldWorldUpdate() {
|
|
|
|
return false;
|
2015-04-03 16:38:24 +02:00
|
|
|
}
|
|
|
|
|
2016-11-30 00:28:53 +01:00
|
|
|
GameWorld* State::getWorld() const {
|
2016-09-09 22:13:20 +02:00
|
|
|
return game->getWorld();
|
2014-09-16 20:22:43 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
GameWindow& State::getWindow() {
|
|
|
|
return game->getWindow();
|
2014-09-16 20:22:43 +02:00
|
|
|
}
|