@Nicox11:
I think that's it. I have posted functions of the Game class related to keyboard input but I don't think it's because of them since the game slows down even when I hold a key that isn't handled by the game.
...and yes it's a good idea, let's see how many events are generated. BTW I have never used a profiler and IDK what's that xD
EDIT 11:55 AM:
Same happens while using the mouse, I mean... If I keep to move the mouse then the game will slow down and will keep processing mouse events until I stop moving it. While moving the mouse it doesn't even print the FPS counter - it freezes completely.
EDIT 12:07 AM:
// main.cpp
sf::RenderWindow window(sf::VideoMode(640, 480), "Mass Agreement");
Game game;
sf::Clock clock;
int fps = 0;
while (window.isOpen())
{
game.RealTimeInput();
sf::Event event;
int event_count = 0;
while(window.pollEvent(event))
{
event_count++;
if (event.type == sf::Event::Closed)
{
window.close();
}
else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
{
return 0;
}
else if(event.type == sf::Event::KeyPressed)
{
game.KeyPressed(event.key.code);
}
}
if(clock.getElapsedTime().asSeconds() >= 1)
{
clock.restart();
printf("FPS: %i\nEvents per second: %i\n", fps, event_count);
fps = 0;
}
window.clear(sf::Color::Black);
game.Draw(&window);
window.display();
fps++;
}
return 0;
FPS: 7
Events per second: 2164
Then when I stop moving the mouse it goes back to normal:
FPS: 31
Events per second: 0