I'm making a game on C++ using SFML 2.4.1 for GCC SJLJ (CodeBlocks with MinGW). When it starts, I want my game to draw the SFML logo (like a splash screen) and, after 3 seconds, draw the title screen's background. Sounds simple, but after displaying the background, after a time it displays the SFML logo again, thus making a loop rather than making the image static. Could you guys help me? This is my code:
#include <Windows.h>
#include <SFML/Graphics.hpp>
int main()
{
// Setting up resources and the window
sf::RenderWindow screen(sf::VideoMode(816, 624), "Elkiria");
sf::Texture tx_sfml;
tx_sfml.loadFromFile("sfml.png");
sf::Sprite sp_sfml;
sp_sfml.setTexture(tx_sfml);
sf::Texture tx_titlebg;
tx_titlebg.loadFromFile("skybg.png");
sf::Sprite sp_titlebg;
sp_titlebg.setTexture(tx_titlebg);
// While the window is opened, do stuff.
while (screen.isOpen())
{
// Create game's event and event's types
sf::Event main_ev;
while (screen.pollEvent(main_ev))
{
if (main_ev.type == sf::Event::Closed) {
screen.close();
}
}
// Operate with the window
screen.clear();
screen.draw(sp_sfml);
screen.display();
Sleep(3000);
screen.draw(sp_titlebg);
screen.display();
}
return 0;
}