#include "constants.h"
#include "Player.h"
+#include "Map.h"
int main ()
{
"DespYrat"
};
- Player test_player{};
-
- sf::Texture t;
- t.loadFromFile("assets/hel_bakgrund.png");
- sf::Sprite s;
- s.setTexture(t);
-
- s.setScale(S_SCALE_KOEFF, S_SCALE_KOEFF);
+ Map game_map{};
+ Player player{};
+ sf::Clock game_clock;
while (window.isOpen())
{
- /* hantera events */
+ // Handle input
sf::Event event;
- // hämta ett event i taget
while (window.pollEvent(event))
{
- if (event.type == sf::Event::Closed)
+ switch (event.type)
{
+ case sf::Event::Closed:
window.close();
+ break;
+ default:
+ break;
}
+
+ player.handle_input(event);
}
- /* rita ut */
- window.clear(); // rensa skärmen
- window.draw(s);
- test_player.render(window);
- test_player.update();
- window.display(); // visa ändringarna
+
+ // Update
+ game_map.update();
+ player.update();
+
+ //Draw
+ window.clear();
+
+ game_map.render(window);
+ player.render(window);
+
+
+ window.display();
+
+ // Make game run at constant fps
+ sf::sleep(sf::milliseconds(1000.0 / FPS) - game_clock.getElapsedTime());
+ game_clock.restart();
+
}
}