• Advertisement
Sign in to follow this  

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

This topic is 460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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!).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement