i was wondering how, if possible, to use the physics in orx in a background thread, that would never be rendered? if for my game, i use the physics logic like 'on_collision' to determine an action and see it on the screen, can i also utilize the calculations made by the physics engine and just save the results somewhere because i'm not interested in seeing them drawn?
extra question, any approximation for how much faster a program could execute without being rendered? is there a way to profile how much time is spent in the different layers of an orx game?
If you don't want the graphics to be displayed, you can create an object without the graphic part. You will need to set its form on the Body parts section by yourself.
Here are two examples (for box and and mesh):
Also keep in mind that you must give the points in counter clockwise order.
Just wondering, why would you need that? The only reason I can think of is to create a server (but then you would probably want the collision to be auto processed in some cases).
Forgot to say: I don't know if you can run orx without a window.
as far as the why, think sports game simulation. if you wanted the same logic applied to a game that the user was playing/viewing and one that was simulated in the background, this would be important.
You can use the orxObject API to update it (for instance, change its position and such).
There are also some automatic updates, for instance, if you call the orxObject_setSpeed, it will automatically process its position according to the given speed.
If the Object has a physics body (and no custom gravity) it will also automatically suffer the gravity force.
Take a look at the physics example and I guess things will be clear, an orxObject may have a physics body and a graphic. When it does, the graphic and the body are attached and will be updated at the same time.
hopefully this is something that can help other types of games as well. i could also see this question applying to a game that might have action going on other 'maps' than the one where the player is currently on.
Sorry for being late to the party. There isn't much that I can add to Knolan's answers anyway.
A few quick points though:
- Is there a way to profile? Yes, look at orxPROFILER_PUSH_MARKER/orxPROFILER_POP_MARKER. Both debug and profile builds are also internally instrumented (not the release one). The profiler can be displayed live by setting the config property Render.ShowProfiler to true, either in a config file or via the interactive console:
press '`' (backquote), and type: (Render and ShowProfiler are case sensitive).
When the profiler is rendered, you can display a short history by pressing Scroll Lock, you can even pause it with Pause and navigate using the arrow keys.
- Can one have physics objects without rendering? Yes, simply don't add the Graphic property to your object (but this has already been covered by Knolan). However keep in mind there's only one physics world simulated, so if you don't want both your virtual simulations to interfere with each others, either use the collision flags appropriately or simply separate their X/Y coordinates by a good amount. There's no restriction on the number of objects without graphics, beside simulation performances (mostly physics).
- Can orx be launched without the display window? Yes, one can look at the code of the orxCrypt and orxFontGen tools: both are built with orx and none of them use (or initialize) the display/render modules and their dependencies.
Let us know if you have any other questions!