question about background processes

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?



  • edited November 2013
    AFAIK you can simply set an object as solid = false and it will detect the colision but won't automatically move the objects (not sure if that is what you want).

    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):
    Type        = box
    TopLeft     = (-28, -29, 0)
    BottomRight = (24, 31, 0)
    Type        = mesh
    VertexList  = (6, 2, 0) # (6, -4, 0) # (12, -1, 0)

    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.
  • edited November 2013
    thanks, i would need the objects moved, so i'll play around with objects without graphics.

    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.
  • edited November 2013
    oh, and maybe i didn't explain the scenario well enough, i don't think it would ever have to run without a window at all. but i would like to be able to run other things in parallel that aren't seen. hope that's more clear.
  • edited November 2013
    In this case I don't think you need an invisible object at all, you can recover all the information, including the physics, of any orxOBJECT that is you create.
  • edited November 2013
    so, i guess what i didn't understand from the tutorials is what part of code is drawing the objects i create? bc essentially what i would want to do is create not just an invisible object, but an invisible 'game' that's running while the user is playing a viewable one.
  • edited November 2013
    When you use the orxObject_CreateFromConfig it will create your object and draw it (assuming it has a Graphic part).

    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.
  • edited November 2013
    thanks, i'll look at the orxObject api's in more depth. maybe a good proof of concept for me to work on would be to make the physics tutorial run in a 'simulated' fashion.

    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.
  • edited November 2013
    Hi willcaliblue, and welcome here!

    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:
    set Render ShowProfiler true
    (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! :)

Sign In or Register to comment.