Thanks for the replies.
I forgot to reset the clock after the end of the game loop, which I now do.
Further, I fixed the FPS calculation, yet now my FPS is hovering around 1.7648.
void Render::render() {
if(!Game::closing && Render::window.isOpen()) {
window.clear();
//Draw all terrain
Terrain::render();
if(Control::renderCursor) {
window.draw(Control::rect);
}
window.display();
}
}
That is the only drawing code present. Terrain::render() simply loops through all block instances:
void Terrain::render() {
//Render whole terrain
int slot = 0;
int line = 0;
for (unsigned int i = 0; i < 3702; i++) {
tileData[i].draw(slot*16,line*16);
//Counter
slot++;
//Reset row count
if (slot == 64) {
slot = 0;
line++;
}
}
}
With this being defined as block::draw(int xx, int yy) :
void block::draw(int xx, int yy) {
//Draw this block
if(!Game::closing) {
sf::RectangleShape rect;
rect.setSize(sf::Vector2f(16, 16));
if(type) {
rect.setFillColor(sf::Color::Black);
} else {
rect.setFillColor(sf::Color::White);
/*
sf::Text text;
text.setString(tileNumber);
text.setCharacterSize(12);
text.setPosition(xx, yy);
text.setColor(sf::Color::Black);
Render::window.draw(text);
*/
}
rect.setOutlineThickness(1);
rect.setOutlineColor(sf::Color::Black);
rect.setPosition(sf::Vector2f(xx, yy));
Render::window.draw(rect);
}
}
And yes, I do realize that I shouldn't be defining the rect parameters in a draw event (redundant+unnecessary).
I also thought that when you set the FPS limit with SFML, it would auto sleep and I wouldn't need to call the Sleep() function manually, however that is obviously not the case here.
Thanks again.