Pseudocode and simplified
class Object
{
int mID; // I find this variable most imprortant!!!
sf::Vector2f mPosition;
sf::Vector2f mSize;
sf::Vector2f mVelocity;
// and rest of variables you may want.
public:
void update();
int getID();
sf::Vector2f getPosition();
sf::Vector2f getSize();
sf::Vector2f getVelocity();
}
class Graphics
{
std::map<int, sf::Sprite> mGraphicObjects; // the int is the ID of the object!!!
public:
void draw(sf::RenderWindow&);
void removeObject(int) // removes the object of particular "int" ID
void addObject(Object); // it takes everything it needs from the object during creation of sprite and puts it in the map container.
void refresh(std::vector<Objects>& mObjectContainter); // assume we have more objects
}
Of course, the real code that I wrote is more complex, but this is in a nutshell. Don't know is it any good, I will probably find out the hard way.
And the priciple is the same for UI objects, if I want to draw them like this.