Looking at the manual it says that he game engine is executing these tasks:
dataloop - Processes the keyboard and mouse inputs
tkloop - Processes Tk GUI events
eventManager - Processes events generated by C++ code, such as collision events
igloop - Draws the scene
I add an extra task called “gameOp” to drive the game logic in my game.
My question is can these tasks be tuned in any way so that i have igloop executing every 1/30 seconds? Tweak other tasks execution times?
About messages we can receive messages with a line of code like this:
But how can we inquire the timestamp when the message has arrived (the in relation to the start of the game that would be zero)?
Is it possible to inquire the number of current frame the game is playing too?
Finnaly is it possible to put the manager sending all events in a sort of “mailbox” list for every game update period (say 1/10 of a second) sorted by timestamp? This would be very useful.
No, that’s not the way the task manager works. It simply runs all tasks, in sequence, and each task takes whatever time it takes. When all tasks have run, it goes back and runs them again. So if you want igloop to execute at least every 1/30 seconds, you have to ensure that all of the other tasks, combined, take less than 1/30 second to execute.
If you want to constrain the task manager to run no faster than 1/30 seconds, you can do this with Config.prc settings. But you can’t force it to run no slower than 1/30 seconds, since it guarantees execution of every task, and they all run in series.
globalClock.getFrameTime() returns the current timestamp of the game. In practice, this generally starts counting at 0 when the game begins, but to be strictly correct you shouldn’t assume this will always be the case.
Sorry, I don’t quite understand what you’re asking for. Events have nothing to do with timestamps, and the messenger doesn’t queue up events; it calls their callback hooks as soon as the event is thrown. (Though C++ events get queued up and executed during the eventManager task.)
Thanks. I think i understand better how the task manager works now.
The Agents in my game are not suposed to process keyboard and mouse events directly. Instead they are put into a queue or “mailbox” as i called it and converted to logical game events. For example the combo “up” followed by “down” then “space” launch a special bomb and would be converted into another logical event called “launch-special-bomb”. The actual key combo used for this could be configured in an options file and be something completely different but the logical event never changes.
Sounds like you want to use a task to empty your mailbox.