I still see a bit of flickering, or it could just be that i am crazy... Here is my code
#include "stdafx.h"
#include "sfml.h"
using namespace sf;
int main()
{
// Create the main window
RenderWindow App(VideoMode(616, 387, 32), "SFML Window");
App.UseVerticalSync(true);
Image img_background;
if(!img_background.LoadFromFile("c://background.png"))
return -1;
Image img_ball;
if(!img_ball.LoadFromFile("c://ball.png"))
return -1;
Sprite background(img_background);
Sprite ball(img_ball);
ball.SetY(325);
while (App.IsOpened())
{
Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == Event::Closed)
App.Close();
if ((Event.Type == Event::KeyPressed) && (Event.Key.Code == Key::Escape))
App.Close();
}
if (App.GetInput().IsKeyDown(Key::Right)) ball.Move(100, 0);
if (App.GetInput().IsKeyDown(Key::Left)) ball.Move(-100, 0);
App.Clear();
App.Draw(background);
App.Draw(ball);
App.Display();
}
return EXIT_SUCCESS;
}
I basically just had two simple images, one background image colored red that was the size of the window, and a white ball image that I moved back and forth... The white ball tends to flicker sometimes though. Any idea why it would? I have solved this flickering issue in the past by just preforming some double buffering, but doesn't seem like you can easily add sprites with in sprites. Any idea what I might be doing wrong? Or is the flickering all in my head :-P