danmaku/application.cpp

38 lines
899 B
C++

#include "application.h"
#include "game.h"
constexpr int SCREEN_WIDTH = 640;
constexpr int SCREEN_HEIGHT = 480;
const sf::Time TIME_PER_SECOND = sf::seconds(1.f / 60.f);
Application::Application() :
render_window({SCREEN_WIDTH, SCREEN_HEIGHT}, "Test")
{}
void Application::registerStates()
{
map_states[State::Tag::Game] = std::make_unique<Game>(render_window, this);
active_state_tag = State::Tag::Game;
}
void Application::run()
{
sf::Clock clock;
sf::Time since_last_update = sf::Time::Zero;
while (render_window.isOpen())
{
map_states[active_state_tag]->processInput();
sf::Time delta = clock.restart();
since_last_update -= TIME_PER_SECOND;
map_states[active_state_tag]->processInput();
//if (!b_pause)
map_states[active_state_tag]->update(delta);
map_states[active_state_tag]->draw();
}
}