scheduling events

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe, G.I.

    scheduling events

    Trying a new approach that I think might work out better than my old
    approach. And this turns out to be a really good reason for me to learn
    boost. Someone else lead me onto this path that I don't fully understand.

    So I'm trying to create 10 events that will start from a random amount
    of time between now and 10 seconds. I have the random generating code
    function that works. And I'm trying to have a scheduler execute my
    events at *that* randomly generated time.

    I have this at the top of one of my *.cpp files

    typedef boost::function <void ()event;

    Then here I create the event which I think binds the die function of the
    Monster class to this void function called 'killMonster'. What does the
    second argument do? This just creates the event and schedules it? Is
    this context.schedul er a part of boost or ... where can I find more
    about creating a scheduler?

    event killMonster = boost::bind(&Mo nster::die, this -target);
    this -context.schedul er.at(NOW + 3.0, killMonster);

    Then I have a function that is called between every frame of my game, so
    that's where I planned on checking the time of the event to see if it
    had expired. Can someone elaborate as to this ... I don't understand how
    that fits in with step_length.

    time += step_length;
    this -context.schedul er.run(time);
Working...