Example #1
0
  void MapScreen::updateMovingPlayer(PlayerInput& input, const GameTime game_time) {
    player_timing_.update(game_time);
    updateInteractions(input);
    player_.update(player_movement_, player_timing_);

    Vector2 destination = movementDestination(player_position_, player_movement_.direction());
    clashing_ = !map_collision_->canMove(player_position_, destination);

    player_timing_.clashing(clashing_);

    if(clashing_) {
      destination = player_position_;
    }

    map_->update(player_timing_.progress(), player_position_, destination);

    if(player_timing_.finished()) {
      player_timing_.reset();
      player_movement_.update(input);

      player_position_ = destination;
    }

    if(clashing_ && maybe_next_screen_) {
      player_movement_.reset();
      player_timing_.reset();
      player_.update(player_movement_, player_timing_);
      pushScreen(std::move(maybe_next_screen_));
    }
  }
Example #2
0
void GUISystem::pauseGameHandler(Event::PauseGame *event) {
    if(event->getPaused()) {
        pushScreen("paused");
    }
    else {
        popScreen("running");
    }
}
Example #3
0
  void MapScreen::updateIdlePlayer(PlayerInput& input) {
    player_movement_.update(input);

    updateInteractions(input);
    if(maybe_next_screen_) {
      pushScreen(std::move(maybe_next_screen_));
    }
  }
Example #4
0
void GUISystem::construct() {
    fontManager = new Render::FontManager();
    textureList = new Render::WidgetTextureList();
    focusManager = new Widget::FocusManager();
    
    LOG(GUI, "Constructing GUI system");
    widgets = GUIConstruction().construct();
    
    pushScreen("main");
    
    METHOD_OBSERVER(&GUISystem::pauseGameHandler);
    METHOD_OBSERVER(&GUISystem::switchToScreenHandler);
}
Example #5
0
void GUISystem::switchToScreenHandler(Event::SwitchToScreen *event) {
    if(event->getScreen().empty()) {
        LOG(GUI, "popping current screen");
        popScreen();
    }
    else if(event->getScreen()[0] == '-') {
        std::string until = event->getScreen().substr(1);
        LOG(GUI, "popping until screen \"" << until << "\"");
        popScreen(until);
    }
    else {
        LOG(GUI, "pushing screen \"" << event->getScreen() << "\"");
        pushScreen(event->getScreen());
    }
}