Hey guys,
currently i am in programming a map editor for a project and i programming it along with the SFML Game Development Book.
My problem is that when i load 65k tiles then my FPS is equal 1 ~ 2 ...
In my TileNode class i already checked if my tiles intersec with our view an it is working
void TileSprite::drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const {
//Not the best way i know...
sf::Vector2u wSize = target.getSize();
sf::Vector2f vPos = target.getView().getCenter();
sf::FloatRect rect{
vPos.x - (wSize.x / 2.f), vPos.y - (wSize.y / 2.f), (float) wSize.x, (float) wSize.y
};
if (getBoundingRect().intersects(rect)) {
target.draw(mSprite, states);
target.draw(*mLayerDisplay, states);
target.draw(*mPositionDisplay, states);
target.draw(*mBlockDisplay, states);
}
}
I really doesn't know why this FPS lag is occuring, but i can think it could happen from the derived class function:
void SceneNode::draw(sf::RenderTarget& target, sf::RenderStates states) const {
// Apply transform of current node
states.transform *= getTransform();
// Draw node and children with changed transform
drawCurrent(target, states);
drawChildren(target, states);
// Draw bounding rectangle - disabled by default
drawBoundingRect(target, states);
}
Can sombody help me to fix this?
I'm really saddened :S