I am making a game in c++ sfml 1.6 and I have encountered a problem.
What I am trying to achieve
Add a life indicator in the top right corner by drawing a string that has the value of the life variable.
What I have done so far
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
int life = 3; // decides how much health you got left (the life variable)
std::ostringstream oss;
oss << life;
sf::String life_string;
life_string.SetText(oss.str());
// in the game loop
App.Draw(life_string);
// in the game loop if my character is dead
life--;
oss << life;
life_string.SetText(oss.str());
}
The problem is that everytime I die a new value gets printed but the old one stays so first it's 3 then its 32 and then its 321 etc
Here is a picture with 0 deaths
Here is a pricture with 2 deaths
so how do I remove the onld value so that there is only 1 value showing