I googled with best of my skills, but I cannot find any relevant answer to my problem. I'm making a game with an isometric view. I need to draw multiple sprites on the screen and before switching to next frame of the sprite, it is needed to clear the last frame of the sprite by doing a clearScreen of the window. If I do clearScreen, all of the other sprites get cleared, since the program cannot remember the last state of the screen. How can I overcome this problem?
Here is my code (I'm writing in pseudo-code, so that the solution can become implementation independent)
main.cpp
{
//gameloop
Animation playerAnimation;
while(window.isopen())
{
window.draw(game_map);
if(certain_condition_is_met)
playerAnimation.update(window)
window.clear()
window.display();
}
}
Animation.cpp
class Animation
{
void update(&window)
{
for(available_frames frame)
window.draw(frame);
//inside the above for loop ,i need to do a clearscreen to avoid overlap of
//frames,but this will make other sprites to be lost
}
}
I'm using C++ SFML, in which there is no way to update a particular sprite without clearScreen.