Object oriented - entities instead of inheritance

4 posts

Flag Post

Hey! I’m making a physics library and I’m currently wondering how to structure it. I said in the 1GAM chatroom that I planned to make shapes and bodies so that you could extend them with your game objects, they said that’s a bad idea. Someone mentioned entities. I’ve haven’t heard about it before and decided to try.

Here’s the body class: http://pastebin.com/661NDhCR

Here’s a game object class: http://pastebin.com/LdvvLdwS

I’m wondering if I’m doing this right.

 
Flag Post

Composition over inheritance basically means: your entity is not a body itself (by extending it) but rather has one (has a variabe of that type.

 
Flag Post

Unless you plan on your physics engine being very basic (Squares & Circles only), your going to have to understand and learn a lot of physics to get a decent engine going. I know as I started one of my own a while back, and it quickly gets complicated.

 
Flag Post

Thanks for replies!

Originally posted by DPbrad:

Unless you plan on your physics engine being very basic (Squares & Circles only), your going to have to understand and learn a lot of physics to get a decent engine going. I know as I started one of my own a while back, and it quickly gets complicated.

I’m up for it anyway! I don’t learn physics at school because I’m in the music class but I want to learn it and I’ve got sources like this to read :) Will implement irregular polygons and circles.