Hi all!
First and foremost, many thank to Eric and this great piece of software. I'm being through the testbed and some other tutorials on the net and I'm finding it easy to use yet responsive enough for my needs.
I'm writing a physics manager for my game engine and I want some tips on which design approach should I take. I don't have much experience with design of large softwares and I can't seem to make a decision on which structure the physics manager should take.
Right now I've thought on the following structure:
the pseudo-code above looks ok for me, but the problem is: where do I insert the collision listeners? BTW, where can I learn more about this listeners thing? It seems like a really important subject, but I can't grasp its true meaning.
First and foremost, many thank to Eric and this great piece of software. I'm being through the testbed and some other tutorials on the net and I'm finding it easy to use yet responsive enough for my needs.
I'm writing a physics manager for my game engine and I want some tips on which design approach should I take. I don't have much experience with design of large softwares and I can't seem to make a decision on which structure the physics manager should take.
Right now I've thought on the following structure:
Code:
class PhysicsManager {
private:
Box2D world's attributes;
collection of body objects (list? map?); //they will be scene based
collision listeners;
public:
init() { //will create shapes, fixtures and bodies
create Body definition based on scene object properties;
create body Object;
create Shape based on scene object properties;
create Fixture definition;
create fixture object;
attach shape to fixture;
attach fixture to body;
push_back body to collection;
}
update () {
step the physics;
}
free() {
delete world;
?delete bodies?;
}
}
};
private:
Box2D world's attributes;
collection of body objects (list? map?); //they will be scene based
collision listeners;
public:
init() { //will create shapes, fixtures and bodies
create Body definition based on scene object properties;
create body Object;
create Shape based on scene object properties;
create Fixture definition;
create fixture object;
attach shape to fixture;
attach fixture to body;
push_back body to collection;
}
update () {
step the physics;
}
free() {
delete world;
?delete bodies?;
}
}
};
the pseudo-code above looks ok for me, but the problem is: where do I insert the collision listeners? BTW, where can I learn more about this listeners thing? It seems like a really important subject, but I can't grasp its true meaning.