Help - Designing collision node, node and physics body classes.

Started by
0 comments, last by LWard 7 years, 5 months ago

Hi, this is my first post :D. I'm writing a 2D game engine in c++ for personal use. Well, let's see....

I have the CollisionNode class which has shapes which define it, can be transformed (rotated, moved, scaled, ...) and can check collisions, by AABB and SAT, with other collision nodes.

The Node class is the base class of the scene graph, it can be transformed too. I think it must to have a way to check collisions, inherit from CollisionNode can be the best choice (I think :)).

Finally the PhysicsBody class is a Collision node affected by physics. To achieve this it can inherit from CollisionNode too.

When I want to use both (Node and PhysicsBody), I'd attach a PhysicsBody to a Node.

Is my design OK??. How would you do it??

Thanks a lot :)

Advertisement

Welcome :)

I think that your design sounds fine.

I would have used a similar approach of having a base class for collision and inheriting off from that to provide different types of collision. For example, BoxCollision and SphereCollision both inherit from Collision, keeping the level of inheritance small, then checking for collisions by testing all Collision type objects (are better ways to find which two objects you need to test rather than cycling over all of them till you find the correct ones!).

This topic is closed to new replies.

Advertisement