To make it meaningful, use char*, not void* (how are you even adding a number to a void*? It doesn't compile on anything I tried, and doesn't make sense logically).
It isn't good practice to find yourself in a situation that requires something like this, but if you are, i think this is sound (except on those rare systems where operator< for pointers does not provide total ordering, so if you want to be paranoid, use std::less instead)
(PS: don't forget to use delete or appropriate smart pointers/containers)
struct tween_t;
struct tween_t;
struct world_t {
list< unique_ptr<object_t> > Objects;
list< unique_ptr<tween_t> > Tweens;
/* more functions here */
} world_1;
template< class T >
struct tween_t {
tween_t( T& element, T dd, double duration, .... );
/* more functions here */
};
struct object_t {
double x,y;
double rot;
sf::IntRect Rect;
sf::Color Color;
image_t * image;
world_t * myworld;
int moveTo(){
myworld->Tweens.push_back( new tween_t<double>(x,100.0, 2.0,... ) );
}
};
I think this is sufficient
My code is too long to be pasted here
When the Objects get destructed because event cause by player
and somehow There is some animation that haven't ended
and still being handling a data to a member of class that doesn't exist anymore
Well I could just put the tween_t handler not in the world_t but in the object_t
And Yeah I will now right away know every tween that handling what object