51 lines
946 B
C++
51 lines
946 B
C++
#include "Game.hpp"
|
|
|
|
Game::Game(sf::RenderWindow& window) : window(window)
|
|
{
|
|
}
|
|
|
|
#include <iostream>
|
|
void Game::run()
|
|
{
|
|
#ifdef _DEBUG
|
|
std::cout << "Loading map... Version: " MAP_VERSION_STRING << std::endl;
|
|
auto start = std::chrono::system_clock::now();
|
|
#endif
|
|
|
|
auto err = map.load(ASSETS_PATH "/test.cymf");
|
|
|
|
#ifdef _DEBUG
|
|
auto end = std::chrono::system_clock::now();
|
|
auto milliseconds = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
|
|
std::cout << "Loading took: " << milliseconds << std::endl;
|
|
#endif
|
|
|
|
map.setPosition(sf::Vector2f{20, 20});
|
|
|
|
if (err.code != 0)
|
|
{
|
|
std::cout << err.message << std::endl;
|
|
return;
|
|
}
|
|
#ifdef _DEBUG
|
|
map.debug();
|
|
#endif
|
|
while (window.isOpen())
|
|
{
|
|
while (const auto event = window.pollEvent())
|
|
{
|
|
if (event->is<sf::Event::Closed>())
|
|
{
|
|
window.close();
|
|
}
|
|
}
|
|
|
|
|
|
// Render game
|
|
window.clear({0x20, 0x20, 0x20,0xff});
|
|
|
|
window.draw(map);
|
|
|
|
window.display();
|
|
}
|
|
}
|