Fix framerate issue

master
NaiJi ✨ 4 years ago
parent 3b7e654ac2
commit b0cb76d419

Binary file not shown.

Binary file not shown.

@ -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,12 +44,12 @@ int Game::run()
{
// Move
onMoving(event.key.code);
// Probably something changed! Re-render
renderMap();
}
}
// Draw level
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…
Cancel
Save