I'm relatively new to both C++ and SFML. I've been slowly working my way through building a small game, but I feel as though my FPS is much lower than it should be. I am using SFML2, and when running my game with 1000 instances of the Player object, I get ~30 fps. This seems very low to me when I read about people drawing tens of thousands of bouncing cubes before their framerate dips like that. It is possible that it is just a hardware limitation, but I would appreciate it if someone would look over my code. The instances are created in the constructor of the World object. I have included all the code as well as the C::B project file.
Here is my draw method. It is slightly modified from the version in the .zip. I have also disabled calls up update() for testing purposes. As a note, my Python version handles drawing 4000+ circles at 60fps.
void Game::draw() {
fpsDrawLoopCounter++;
window.clear();
std::stringstream ss;
ss << "FPS: " << lastReportedFPS << std::endl;
if (state == State::PAUSED) {
ss << "PAUSED" << std::endl;
}
sf::Text fpsText(ss.str(), systemFont, 16);
fpsText.setPosition(10, 10);
window.draw(fpsText);
sf::CircleShape s;
std::vector<GameObject *>::const_iterator it = world.get_objectList().begin();
while (it != world.get_objectList().end()) {
//window.draw((**it).get_sprite());
s.setRadius(10);
s.setPosition((**it).get_sprite().getPosition());
s.setFillColor(sf::Color::Green);
window.draw(s);
++it;
}
window.display();
}
https://www.dropbox.com/s/wg9skyyyw7st9z0/FirstGame.zip