Display/update loop

 

 

A simple display/update loop:

 

while (TRUE)

{

while (elapsed < frame_time);

DisplayScene();

UpdateScene();

}

 

 

A fancier display/update loop:

 

while (TRUE)

{

while (elapsed < frame_time)

{

DisplayScene();

     }

UpdateScene(elapsed);

}

 

Actors

 

 

typedef enum

{

ACT_RIGHTWING,

ACT_CENTER,

ACT_GOALIE,

ACT_WATERBOY,

ACT_CHEERLEADER1,

}

Actor* gameActors[MAX_ACTORS];

 

 

Tasks

 

 

if (InGoal(ball, goal))

{

  SetTask(ACT_GOALIE, TASK_COLLAPSE);

  SetTask(GetGoalScorer(), TASK_CELEBRATE);

  for (i=0; i<NUM_CHEERLEADERS; i++)

  {

    SetTask(ACT_CHEERLEADER1+i, TASK_SHAKEIT);

  }

}

 

More on displays

 

void DisplayActors()

{

     for (actorNum=0; actorNum<NUM_ACTORS; i++)

     {

     Actor* actor = gameActors[actorNum];

DisplayFrame(actorNum,

gameAnimations[actor->currTask][actor->currFrame];

     }

}

 

State Machines