Switching to sfml
This commit is contained in:
parent
4536c62dad
commit
de72aead56
40 changed files with 462 additions and 2385 deletions
46
src/Game.cpp
Normal file
46
src/Game.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include "Game.hpp"
|
||||
|
||||
Game::Game(sf::RenderWindow& window) : window(window)
|
||||
{
|
||||
enemies.emplace_back(sf::Vector2f{100, 100});
|
||||
enemies.emplace_back(sf::Vector2f{200, 200});
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
void Game::run()
|
||||
{
|
||||
std::cout << "Loading map... Version: " MAP_VERSION_STRING << std::endl;
|
||||
auto start = std::chrono::system_clock::now();
|
||||
auto err = map.load(ASSETS_PATH "/test.cymf");
|
||||
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;
|
||||
if (err.code != 0)
|
||||
{
|
||||
std::cout << err.message << std::endl;
|
||||
return;
|
||||
}
|
||||
map.debug();
|
||||
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});
|
||||
|
||||
for (auto& enemy : enemies)
|
||||
{
|
||||
window.draw(enemy);
|
||||
}
|
||||
window.draw(map);
|
||||
|
||||
window.display();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue