Fix framerate issue
This commit is contained in:
parent
3b7e654ac2
commit
b0cb76d419
Binary file not shown.
Binary file not shown.
19
src/game.cpp
19
src/game.cpp
|
@ -20,16 +20,16 @@ Game::Game()
|
|||
|
||||
main_window.create(sf::VideoMode(window_side * 3, window_side * 3), "SFML-Test Application", sf::Style::Default);
|
||||
main_window.setActive();
|
||||
|
||||
level->mapArray()[0][0]->setHeightShift(15);
|
||||
level->mapArray()[0][1]->setHeightShift(10);
|
||||
main_window.setFramerateLimit(60);
|
||||
|
||||
current_level = 1;
|
||||
//loadLevel(current_level);
|
||||
}
|
||||
|
||||
int Game::run()
|
||||
{
|
||||
// Initial level rendering
|
||||
renderMap();
|
||||
|
||||
// On the game loop
|
||||
while (main_window.isOpen())
|
||||
{
|
||||
|
@ -44,11 +44,11 @@ int Game::run()
|
|||
{
|
||||
// Move
|
||||
onMoving(event.key.code);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw level
|
||||
// Probably something changed! Re-render
|
||||
renderMap();
|
||||
}
|
||||
}
|
||||
|
||||
main_window.display();
|
||||
}
|
||||
|
@ -118,6 +118,11 @@ void Game::renderMap()
|
|||
float painter_x = 60, painter_y = 60;
|
||||
float horizontal_shift = 0, vertical_shift = 0;
|
||||
|
||||
sf::RectangleShape background_brush({static_cast<float>(main_window.getSize().x), static_cast<float>(main_window.getSize().y)});
|
||||
background_brush.setFillColor(palette::Black);
|
||||
background_brush.setPosition(0.f, 0.f);
|
||||
main_window.draw(background_brush);
|
||||
|
||||
// Brush for cell sprites
|
||||
sf::ConvexShape convex_brush;
|
||||
convex_brush.setPointCount(4);
|
||||
|
|
Loading…
Reference in New Issue