home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / Life Simulator / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-04  |  1.2 KB  |  59 lines  |  [TEXT/MMCC]

  1. /* Cell Proj 1.0 */
  2.  
  3. /********************************************************************
  4.  Ported to Metrowerks CodeWarrior by Paul Celestin on 4 November 1994
  5.  ********************************************************************/
  6.  
  7. #include "Cell_Proto.h"
  8. #include "Cell_Definitions.h"
  9. #include "Cell_Variables.h"
  10.  
  11. EventRecord        gTheEvent;
  12. Boolean            gWNEImplemented, gDone;
  13. MenuHandle        gAppleMenu, gFileMenu, gAbilityMenu;
  14. WindowPtr        gCellWindow;
  15. Rect            gDragRect, gSizeRect;
  16. DialogPtr        gCellInfoDialog;
  17. long            gOverExp, gOverPop;
  18.  
  19. int                gCellStatus[ NUMBER_OF_CELLS ];
  20.  
  21. main()
  22. {
  23.     gDone = FALSE;
  24.     ToolBoxInit();
  25.     WindowInit();
  26.     DialogInit();
  27.     MenuBarInit();
  28.     SetUpDragRect();
  29.     DisplayCellWindow();
  30.     PlaceRandomCells();
  31.     MainLoop();
  32. }
  33.  
  34. MainLoop()
  35. {
  36.     while ( gDone == FALSE )
  37.     {
  38.         gWNEImplemented = ( NGetTrapAddress( WNE_TRAP_NUM, ToolTrap ) !=
  39.                             NGetTrapAddress( UMIMPL_TRAP_NUM, ToolTrap ) );
  40.         if ( gWNEImplemented )
  41.             WaitNextEvent( everyEvent, &gTheEvent, MIN_SLEEP, NIL_MOUSE_REGION );
  42.         
  43.         else
  44.         {
  45.             SystemTask();
  46.             GetNextEvent( everyEvent, &gTheEvent );
  47.         }
  48.         
  49.         DoPreCheck();
  50.         
  51.         if ( IsDialogEvent( &gTheEvent ) )
  52.         {
  53.             HandleDialog();
  54.         }
  55.         
  56.         else
  57.             HandleEvent();
  58.     }
  59. }