How to keep my game engine compatible with physics engines (HTML5

Started by
2 comments, last by speciesUnknown 11 years, 9 months ago
I posted this on GDSE as well, but it might be "too discussiony" for that site...

I'm making a game engine, but I would like to have the physics part handled by professionally built physics engines, because I couldn't do it my self. My engine supports Scene handling, Cameras, and has a Renderer. Also, it has a class called Drawable, which has the positions 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 (collection of Tiles, that also inherit from Drawable), lights, and so on and so forth.

I am considering adding a shape property (user-defined polygon) to the Drawable class as well, which would be used for shadows and such.

I am asking this question with a premise that most physics engines work in a similar way, and impose similar limitations. Is there anything I can do to make my engine more compatible wuth those physics engines?

Edit: what exactly do physics engines need to control? For example, if a physics engine supported a way of creating objects with position and shape(bounding box?) properties, that would be in obvious collision with my model, where Drawables had their pos and shape properties.
Advertisement
Try out box2dweb, its the as3 version of box2d converted into JS.

The way they work is that you put bodies into the physics world, and then step the physics simulation - it will resolve collisions and things to give you the new position of your rigid bodies.

Let your logic entities put rigid bodies into the physics scene when they are added to the world, and remove them when they are removed from the world. When you update, update the physics system first, and then let your logic entities get their new positions from their rigid body or bodies.

This will all make sense once you have done it for real.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!

Try out box2dweb, its the as3 version of box2d converted into JS.

The way they work is that you put bodies into the physics world, and then step the physics simulation - it will resolve collisions and things to give you the new position of your rigid bodies.

Let your logic entities put rigid bodies into the physics scene when they are added to the world, and remove them when they are removed from the world. When you update, update the physics system first, and then let your logic entities get their new positions from their rigid body or bodies.

This will all make sense once you have done it for real.


So basically the physics engines don't and shouldn't work with real game entities, but abstractions? I'll look into the API, because that would be great!

[quote name='speciesUnknown' timestamp='1340641132' post='4952692']
Try out box2dweb, its the as3 version of box2d converted into JS.

The way they work is that you put bodies into the physics world, and then step the physics simulation - it will resolve collisions and things to give you the new position of your rigid bodies.

Let your logic entities put rigid bodies into the physics scene when they are added to the world, and remove them when they are removed from the world. When you update, update the physics system first, and then let your logic entities get their new positions from their rigid body or bodies.

This will all make sense once you have done it for real.


So basically the physics engines don't and shouldn't work with real game entities, but abstractions? I'll look into the API, because that would be great!
[/quote]

That's sort of how it works; they would have a hard time understanding your game entities. Its more a case of specialisation than limitation though. If your objects can be represented by rigid bodies, or processed using queries, you will go far.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!

This topic is closed to new replies.

Advertisement