コード例 #1
0
ファイル: main.cpp プロジェクト: evavro/Artificial-Fun
int main()
{
//define this to send output to a text file (see locations.h)
#ifdef TEXTOUTPUT
  os.open("output.txt");
#endif

  //seed random number generator
  srand((unsigned) time(NULL));

  //create a miner
  Miner* Bob = new Miner(ent_Miner_Bob);

  //create his wife
  MinersWife* Elsa = new MinersWife(ent_Elsa);

  //create barfly
  BarFly* Henry = new BarFly(ent_Henry);

  //register them with the entity manager
  EntityMgr->RegisterEntity(Bob);
  EntityMgr->RegisterEntity(Elsa);
  EntityMgr->RegisterEntity(Henry);

  //run Bob and Elsa through a few Update calls
  for (int i=0; i<30; ++i)
  { 
    Bob->Update();
    Elsa->Update();
	Henry->Update();

    //dispatch any delayed messages
    Dispatch->DispatchDelayedMessages();

    Sleep(800);
  }

  //tidy up
  delete Bob;
  delete Elsa;
  delete Henry;

  //wait for a keypress before exiting
  PressAnyKeyToContinue();


  return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: jms8142/Miner
int main()
{
    
#ifdef TEXTOUTPUT
    os.open("output.txt");
#endif
    
    //seed random number generator
    srand((unsigned) time(NULL));
    
    Miner* Bob = new Miner(ent_Miner_Bob);
    MinersWife* Elsa = new MinersWife(ent_Elsa);
    Cat* Kitty = new Cat(ent_Cat);
    
    
    EntityMgr->RegisterEntity(Bob);
    EntityMgr->RegisterEntity(Elsa);
    EntityMgr->RegisterEntity(Kitty);
    
    for(int i=0; i<30;++i){
        Bob->Update();
        Elsa->Update();
        Kitty->Update();
        Dispatch->DispatchDelayedMessages();
        
        
        usleep(500000);

    }
    
   
    delete Bob;
    delete Elsa;
    delete Kitty;
    
    return 0;
    
}