My engine supports scene handling, cameras, and has a renderer. Also, it has a class called Drawable, which has the position, the shape and the picture of an object. The picture property has width, height, rotation and a draw method. All game objects are supposed to inherit from this Drawable class, and are added to the scene, along with a map (a collection of Tiles, that also inherit from Drawable), lights, and so on and so forth.

The shape property of a Drawable is a Polygon, a collection of user defined vertices around the position of a Drawable. This is a relative coordinate system, so [0, 0] is the position of the Drawable.

With this setup, will the users of my engine (which will probably only be me) still be able to integrate physics engines such as Box2DJS into their games?

  • 5
    \$\begingroup\$ You should do some quick research into various physics engines' APIs and "bouncing box" sample codes, to get rid of the 800lb gorilla in the room: "a premise that most physics engines work in a similar way" and replace it with real knowledge to work with. \$\endgroup\$ Commented Jun 25, 2012 at 16:08

1 Answer 1


From what I can see there are two ways of doing this.

The first option is to build your engine around the the idea of composition. The idea being that an end users game won't inherit anything you have made, but will hold instances of the relevant classes in objects they want to construct. For example;

    Drawable Draw;

The other options is to just pick a physics engine that works with your system and add it in. It limits the end uses choice, but you may also find people appreciate it more because you can then change your engine interface to allow for easier creation of complex objects for which a physics engine in necessary.

  • \$\begingroup\$ Hi, please see the edit I made. \$\endgroup\$
    – jcora
    Commented Jun 25, 2012 at 16:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .