Hi. Im used to SFML 1.2 and updated my verision to 1.5 today and i dunno if this is one major bugg or just my code.
This is a labbingcode for a project im doing in school so dont lol at the code.
while (App.IsOpened())
{
// Handle events
Event Event;
while (App.GetEvent(Event))
{
// Window closed or escape key pressed : exit
if ((Event.Type == Event::Closed) ||
((Event.Type == Event::KeyPressed) && (Event.Key.Code == Key::Escape)))
{
App.Close();
break;
}
}
if (App.GetInput().IsKeyDown(Key::Left))
{
hero.move_x(-1);
my_room.move_x(2);
}
if (App.GetInput().IsKeyDown(Key::Right))
{
hero.move_x(1);
my_room.move_x(-2);
if(hero.avatar->x == 300)
{
for(int i=hero.avatar->x;i!=0;i--)
{
hero.move_x(-1);
my_room.move_x(-2);
//Sleep(0.1);
}
}
}
my_room.display(&App);
hero.display(&App);
App.Display();
//i++;
}
return EXIT_SUCCESS;
return 0;
}
void room::display(RenderWindow * App)
{
App->Draw(wallpaper->my_picture);
}
void room::move_x(int value)
{
wallpaper->x += value;
wallpaper->my_picture.SetX(wallpaper->x);
}
void character::display(RenderWindow * App)
{
App->Draw(avatar->my_picture);
}
void character::move_x(int value)
{
avatar->x += value;
avatar->my_picture.SetX(avatar->x);
}
Simpley i have two pictures one in the background and one character over it. When heros x reaches 300 it will loop down(like in megaman)
But after the loop had done his work ive now got two heroes on the screen. Is this something common? + the pictures is moving and stuff when the second hero appears.