In a game I'm working on I have two C++ classes (ICollidable and Sprite) which both virtually inherit another C++ class called Object, for its properties Position and Size. I have these three classes exposed to python with boost python. The Player class constructor in python looks like this for example:
class Player(Game.ICollidable, Game.Sprite, Game.IKeyboardListener, Game.IEntity):
def __init__(self):
Game.IKeyboardListener.__init__(self)
Game.IEntity.__init__(self)
Game.ICollidable.__init__(self)
Game.Sprite.__init__(self)
The problem is that when the Sprite init comes before ICollidable's init the Sprite position doesn't work correctly, and I cant reposition the sprite on the screen. I think whats happening is that there are separate instances of the position from Sprite and ICollidable which is what I thought would happen before I made the ICollidable class.
I've tried a variety of things to try and solve this problem and scoured the internets to find solutions to a problem like this one but I've come up empty handed. Any advice, solutions or hints would be greatly appreciated.
Edit:
These are the python bindings to my C++ classes:
class_<Object>("GameObject")
.def_readwrite("Pos", &Object::pos)
.def_readwrite("Size",&Object::size)
;
class_<Sprite, bases<Object>>("Sprite", init<>())
// Sprite(TexID, Pos)
.def(init<GLuint, glm::vec2>())
// ----------------------------
.def_readwrite("TexId", &Sprite::texid)
;
class_<ICollidableWrap, bases<Object>,boost::noncopyable>("ICollidable", init<>())
//.def("Pos", &ICollidable::Object::pos)
.def("Test", pure_virtual(&ICollidable::Test))
.def("OnCollision",pure_virtual(&ICollidable::OnCollision))
;