danmaku/application.cpp

38 lines
899 B
C++
Raw Normal View History

2021-01-09 11:41:58 +01:00
#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();
}
}