SFML community forums
Help => Window => Topic started by: calccrypto on January 15, 2012, 11:58:24 pm
-
Im getting a weird problem that I dont believe that i should be getting, and yet the program is so simple that I dont know where it could have gone wrong. this code:
#include <SFML/Graphics.hpp>
int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
App.Clear(sf::Color(200, 0, 0));
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
which i got off of the tutorials, with a minor change (App.Clear(sf::Color(200, 0, 0)); ) causes the screen to flash like crazy (from black to the input color: in this case, red). why is that? how can i fix this? im simply trying to set the background to some color besides black
-
Your "Clear()" should be inside your while loop.
Usually your game loop would look like this:
While(playing)
{
// Process events
//collect and act upon user input?
Clear();
///Draw stuff
Display();
}
-
thanks!