home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 21 / amigaformatcd21.iso / mui / mui_developer / extclasses / mcc_tron / developer / c / examples / tron-demo.c < prev   
Encoding:
C/C++ Source or Header  |  1997-03-10  |  3.2 KB  |  160 lines

  1. /*
  2.  
  3.         Tron.mcc (c) Copyright 1995-96 by kmel, Klaus Melchior
  4.  
  5.         Example for Tron.mcc
  6.  
  7.         tron-demo.c
  8.  
  9. */
  10.  
  11. /* SMAKE */
  12.  
  13.  
  14. #ifdef __KMEL
  15.     #include <kmel/kmel.h>
  16.     #include <kmel/kmel_debug.h>
  17.  
  18.     #include <mui/tron_mcc.h>
  19.  
  20.     #include "rev/Tron-Demo.rev"
  21.  
  22.     extern char *vers_string;
  23. #else
  24.     #include <clib/alib_protos.h>
  25.     #include <clib/exec_protos.h>
  26.     #include <clib/graphics_protos.h>
  27.     #include <clib/utility_protos.h>
  28.     #include <clib/muimaster_protos.h>
  29.     #include <pragmas/muimaster_pragmas.h>
  30.     #include <libraries/mui.h>
  31.     #include <stdio.h>
  32.  
  33.     #include "mui/tron_mcc.h"
  34.     #include "rev/Tron-Demo.rev"
  35.  
  36.     #define DB / ## /
  37.     #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  38.  
  39.     char *vers_string  = __VSTRING;
  40.     char *vers_tag = __VERSTAG;
  41. #endif
  42.  
  43. /*** externals ***/
  44. extern struct Library *SysBase;
  45.  
  46. /*** main ***/
  47. int main(int argc,char *argv[])
  48. {
  49.     struct Library *IntuitionBase;
  50.     int ret=RETURN_ERROR;
  51.  
  52.     if(IntuitionBase = OpenLibrary("intuition.library", 36))
  53.     {
  54.         struct Library *MUIMasterBase;
  55.  
  56.         if(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, 13))
  57.         {
  58.             APTR app;
  59.             APTR window;
  60.             APTR tr_game, bt_start, bt_stop;
  61.  
  62.             ULONG signals;
  63.             BOOL running = TRUE;
  64.  
  65.             app = ApplicationObject,
  66.                 MUIA_Application_Title      , "Tron-Demo",
  67.                 MUIA_Application_Version    , vers_string,
  68.                 MUIA_Application_Copyright  , __VERSCR,
  69.                 MUIA_Application_Author     , "Klaus Melchior",
  70.                 MUIA_Application_Description, "Demonstrates the Tron class.",
  71.                 MUIA_Application_Base       , "TRONDEMO",
  72.  
  73.                 SubWindow, window = WindowObject,
  74.                     MUIA_Window_Title, "TronClass",
  75.                     MUIA_Window_ID   , MAKE_ID('T','R','O','N'),
  76.                     MUIA_Window_Width, 240,
  77.                     WindowContents, VGroup,
  78.  
  79.                         /*** create a Tron game ***/
  80.                         Child, tr_game = TronObject,
  81.                             GaugeFrame,
  82.                             End,
  83.  
  84.                         Child, HGroup,
  85.                             Child, bt_start = KeyButton("Start", 'a'),
  86.                             Child, bt_stop = KeyButton("Stop", 's'),
  87.                             End,
  88.  
  89.                         End,
  90.  
  91.                     End,
  92.                 End;
  93.  
  94.             if(app)
  95.             {
  96.                 /*** generate notifies ***/
  97.                 DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  98.                     app, 2,
  99.                     MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  100.  
  101.                 DoMethod(bt_start, MUIM_Notify, MUIA_Timer, MUIV_EveryTime,
  102.                     tr_game, 3,
  103.                     MUIM_Set, MUIA_Tron_Running, TRUE);
  104.                 DoMethod(bt_stop, MUIM_Notify, MUIA_Timer, MUIV_EveryTime,
  105.                     tr_game, 3,
  106.                     MUIM_Set, MUIA_Tron_Running, FALSE);
  107.  
  108.                 /*** ready to open the window ... ***/
  109.                 set(window,MUIA_Window_Open,TRUE);
  110.  
  111.                 set(tr_game, MUIA_Tron_Running, TRUE);
  112.  
  113.                 while (running)
  114.                 {
  115.                     switch(DoMethod(app,MUIM_Application_Input,&signals))
  116.                     {
  117.                         case MUIV_Application_ReturnID_Quit:
  118.                             running = FALSE;
  119.                             break;
  120.                     }
  121.  
  122.                     if(running && signals)
  123.                         Wait(signals);
  124.                 }
  125.  
  126.                 set(tr_game, MUIA_Tron_Running, FALSE);
  127.  
  128.                 set(window, MUIA_Window_Open, FALSE);
  129.  
  130.                 /*** shutdown ***/
  131.                 MUI_DisposeObject(app);      /* dispose all objects. */
  132.  
  133.                 ret = RETURN_OK;
  134.             }
  135.             else
  136.             {
  137.                 puts("Could not open application!");
  138.                 ret = RETURN_FAIL;
  139.             }
  140.  
  141.             CloseLibrary(MUIMasterBase);
  142.         }
  143.         else
  144.         {
  145.             puts("Could not open muimaster.library v13!");
  146.             ret = RETURN_FAIL;
  147.         }
  148.  
  149.         CloseLibrary(IntuitionBase);
  150.     }
  151.     else
  152.     {
  153.         puts("Could not open intuition.library v36!");
  154.         ret = RETURN_FAIL;
  155.     }
  156.  
  157.     return(ret);
  158. }
  159.  
  160.