object based clocks

tada! disney magic! here's a conversation I was having with iarwain that I'm posting here for others to see.
orx clock
7 messages
Eyecreate Sun, Nov 15, 2009 at 7:14 PM
To: iarwain
I have a question about the orx clock. Do you have to use the clock measurement as part of calculations in order for it to slow stuff down, or can it be"applied" to objects. I ask because it seems in the examples that you use it in the calculations in order to transform them.



iarwain Sun, Nov 15, 2009 at 7:52 PM
To: Eyecreate
Hi,

Yes, you have to use the time info you get from the clock to ensure
time correctness in your calculations.
However, when you use functions such as
SetSpeed()/SetAngularVelocity(), if you stretch the time for the
physics clock, it will impact the object movements for objects that
have a body and the core clock for other objects.

I need to figure out a nice way of uniformising this as the objects
with bodies are updated by the physics plugin (Box2D) whereas the
other are updated manually in orx's core.
In the end I'd like to be able to group objects on separate clocks and
those clocks will finally give the information to whoever is updating
the object. I have an idea I'd like to try but it's still on my todo
list. :)

2009/11/15 Eyecreate
iarwain Sun, Nov 15, 2009 at 7:59 PM
To: Eyecreate
Actually, after giving some thoughts to it, my idea looks pretty easy
to try so if it's something you need soon I can give it a try next
week whenever I find the time.

2009/11/15 iarwain
Eyecreate Sun, Nov 15, 2009 at 7:59 PM
To: iarwain
so, in short, the built in clocks are one for physics, which affects all physics, and one core, which affects all core objects. Then any clock you make yourself you have to manually put into the code. Is this right? I was planning on using the clocks to slow down all objects but the player object, but it would be even more difficult because most of the object I was going to have using the physics engine too.





Eyecreate Sun, Nov 15, 2009 at 8:13 PM
To: iarwain
if you can get it so that each object can have a clock attached to it: ex.
[player1]
clock=playerclock
[bullets]
clock=sceneclock
[enemies]
clock=sceneclock
[playerclock]
speed=1
[sceneclock]
speed=0.5

Where each of those clocks can be attached to an object, which then relays it to where it's needed, that would work out great and save me alot of time. Of course, as I said, most my objects will be using physics too, so it'd mean each physics object would need to to have a different clock, which I'm not sure how plausible it is.(I think you said the whole physics has just one clock, but not sure if what you said you could do would fix that for individual objects. If I'm not clear, please tell me. :D







iarwain Sun, Nov 15, 2009 at 8:41 PM
To: Eyecreate
Yes, for the built-in clocks. There are a couple of others too, but of
no interests to you (such as the FPS clock being ticked once per
second, etc...).

The clocks you create for your logic to be updated, whenever you
slow/accelerate them, if you use the DT/Time info they give you, your
logic will be stretched in consequence. However their physical
movement when using the SetSpeed()/SetAngularVelocity() only won't be
affected. If you use SetPosition and calculating the speed yourself
with the info your clock sends you, you're fine, but it's not very
practical.

When I'm done with the idea I want to do, if it works, you won't have
to do anything with your player and just call something like
orxObject_SetClock() on your other objects so as to bind them to a
clock you've created and that you'll slow down/accelerate at will.
I'll make sure everything related to an object will be updated
accordingly, such as its physical properties (speed/angular velocity),
Spawner rate, FXs, animations. As for the sound, I could also alterate
the pitch accordingly I presume.


iarwain Sun, Nov 15, 2009 at 8:48 PM
To: Eyecreate
That would be the 2nd step, when the system works. Right now there's
no config for clocks and they aren't centralized like camera for
example. It can be done but requires some more work. :)

Also, if you want something less tedious to write in the config, I'd go with:

[ObjectBase]
Clock = SceneClock
And you can add any other 'common' properties for your objects

[Bullets@ObjectBase]

[Enemies@ObjectBase] etc, ...

A clock would be something like

[ClockTemplate]
Frequency = [Float]; in Hz
Modifier = multiply | fixed
ModifierValue = [Float]


And for the physics objects, there is only one clock to update the
whole simulation (can't change this, it's in Box2D) however, everytime I
update an object, I'll change its internal speed in Box2D according to
the clock to which the object is bound, but externally you'll still
see the values you've given to the object. That's the easiest way of
hacking things so they work in the same way for physics/non-physics
objects. What do you think?

Don't hesitate to post this on the feature request part of the forum
so that others can give their thoughts about it too. =)

Comments

  • edited November 2009
    So if someone has enough courage to read the whole thing, let us know what you think of it. I'll give my idea a try during next week unless better ones are proposed. :)
  • edited November 2009
    another thing I'd like to ask related to this: If I try to bypass Orx to manipulate joints in box2d, will the joints not be able to be clock controlled? I'd assume not, but just asking. I think mostly just the player will have joints, and the player probably won't need to be slowed, but I might need it if I change game design(ex. NPCs having full body joints too), so , just asking.
  • edited November 2009
    That's a good question. I know I can trick Box2D to simulate the differents clocks for speed and angular velocity, but I don't know how it works with joints.
    Maybe it's something to ask on Box2D forum if someone ever tried to do such a thing but I'm afraid orx doesn't have any direct control over it.
    I assume joints wouldn't be such a problem though, probably more motors as joints would react to stimuli in a time-consistent way. Motors however don't react but act and there might be some parameter to change according to one object's linked clock, but it's pure speculation on my side. :)
  • edited November 2009
    Fast update: in the past hour I added support for localized clocks like mentioned above. So far so good but I haven't done the Box2D physics part yet: works well for every structures linked on an object, except the sound, and for the simple home dynamic (when no collision object is linked to an object).

    As soon as this works in every cases (sound included), I'll add the data-driven feature for the clocks (probably tomorrow or before the end of the week anyway).
  • edited November 2009
    Ok, the first version has been commited on the svn repository. I did some basic testing for physics (both bodies & non-bodies), FXs and sound and everything looked fine.

    As I don't trust in code working perfectly at first try, please let me know whenever you find the bugs! :)

    I still need to have config handling for clocks. Right now you can associate clocks with code using orxObject_SetClock()/orxObject_GetClock().
  • edited November 2009
    Thanks bunches! I'll see if I know enough to cook up a test for this feature and give feedback accordingly. Also, glad to see __orxWII__ in the change-log, as I was going to try and port my game to that platform when it was done, but look at me talking when I haven't even started it yet. :D Let me know when Scroll is ready to test too, as it's another item high on my list to try and use.
  • edited November 2009
    Yes, __orxWII__ has been added but it's not me that will work on this version. I'll keep you posted when there'll have some more news on this version. :)

    As for Scroll, the alpha is ready, I couldn't add the last feature I wanted (backups when saving) as it turned out 5 functions of orxFileSystem haven't been implemented by their author back in the days when I wasn't alone in the team. Unfortunately I haven't time to add them now, so the backup feature will wait for Scroll beta! ;)

    I still need a very simple idea of a level-based game to ship an example with Scroll (something I can code within a couple of hours would be nice). If I get no ideas, I'll probably add a "ship" and some random simple enemies to kill to finish a level. However, game design/level design definitely isn't my strength! :)
  • edited November 2009
    how about this? Do something that is a classic game, in order to keep it easy to make, but with a twist. An example could be Snake but there are walls on the inside of the field that must be destroyed with bullets. Shooting at the inner walls breaks them and allows you to go through the wall. The apples will be randomly placed inside different sections of the walls. Running into a wall will lose you a life. Outer walls can either be non-breakable, or can cycle the snake to the other side of the screen.Also, instead of the snake growing bigger when an apple is eaten, it moves faster. Different levels have different shape rooms or more complicated walls.
  • edited November 2009
    Thanks for the idea! =)

    I might go with something like this if I'm not too lazy! ;)
  • edited November 2009
    As seen here, Clocks can now be created through the config system and associated to objects with the Object.Clock property. SVN version only for now. :)
Sign In or Register to comment.