home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / SAT / myPlatform ƒ / myPlatform.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-26  |  2.6 KB  |  107 lines  |  [TEXT/KAHL]

  1. #include "SAT.h"
  2.  
  3. /**************/
  4. /* myPlatform demo*/
  5. /**************/
  6.  
  7. /* This demo is a hack I made, testing if we can use faceless sprites to make stationary*/
  8. /* obstacles. That worked pretty nicely, so I went on and made some moving platforms too.*/
  9. /* Take it for what it is: a test hack that suggests one way to make this kind of games.*/
  10. /* There are many other ways. The controls can be improved a lot, but it is a start.*/
  11.  
  12. /* Translated to C by Mike Zimmerman */
  13.  
  14. #include "myPlatform.h"
  15.  
  16. SATPatHandle    thepat;
  17. long             L;
  18. SpritePtr        ignoreSp;
  19. Point            p;
  20.  
  21. void DrawInfo()
  22. {
  23.     Rect    r;
  24.     
  25.     SetPort(gSAT.backScreen);
  26.     SetRect(&r, 100, 50, 300, 100);
  27.     EraseRect(&r);
  28.     FrameRect(&r);
  29.     MoveTo(110, 70);
  30.     DrawString("\pSAT Platform demo");
  31.     MoveTo(110, 90);
  32.     DrawString("\pMove with , . and space");
  33.     SATBackChanged(&r);
  34. }
  35.  
  36.  
  37. main()
  38. {
  39.     Rect        tempRect;
  40.  
  41.     MaxApplZone ();
  42.     FlushEvents (everyEvent - diskMask, 0 );
  43.     InitGraf (&thePort);
  44.     InitFonts ();
  45.     InitWindows ();
  46.     InitMenus ();
  47.     TEInit ();
  48.     InitDialogs (nil);        /* no restart proc */
  49.     InitCursor ();
  50.  
  51.     MoreMasters ();
  52.     MoreMasters ();
  53.  
  54.  
  55. /* End of initializations */
  56.  
  57.     ConfigureSAT(true, kLayerSort, kBackwardCollision, 32);
  58.     InitSAT(0, 0, 512, 322);  /* No PICTs */
  59.  
  60.     /* Use a background pattern (instead of PICTs - just to demo that too) */
  61.     
  62.     SetPort(gSAT.backScreen);  
  63.     thepat = SATGetPat(128);
  64.     SATPenPat(thepat);
  65.     SetRect(&tempRect, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  66.     PaintRect(&tempRect);
  67.     
  68.     CopyBits(&(gSAT.backScreen)->portBits, &gSAT.offScreen->portBits, &gSAT.offScreen->portRect, &gSAT.offScreen->portRect, srcCopy, nil);
  69.  
  70.     DrawInfo();
  71.     
  72. /*Initialize all sprite units*/
  73.     InitPlayerSprite();
  74.     InitPlatform();
  75.     InitMovPlatform();
  76.     InitHMovPlatform();
  77.     
  78. /*Show the game window and update it. (SATwind and gameWind are the same.)*/
  79.     ShowWindow(gSAT.wind);
  80.     SelectWindow(gSAT.wind);
  81.     PeekOffscreen();
  82.     
  83.     SetRect(&tempRect, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  84.       CopyBits(&(gSAT.offScreen->portBits), &(gSAT.wind->portBits), &tempRect, &tempRect, srcCopy, nil);
  85.  
  86.     GetMouse(&p);
  87.     ignoreSp = NewSprite(1, p.h, p.v, &SetupPlayerSprite);
  88.     ignoreSp = NewSprite(0, 50, 300, &SetupPlatform);
  89.     ignoreSp = NewSprite(0, 150, 200, &SetupPlatform);
  90.     ignoreSp = NewSprite(0, 250, 100, &SetupPlatform);
  91.     ignoreSp = NewSprite(0, 350, 50, &SetupPlatform);
  92.     ignoreSp = NewSprite(0, 350, 300, &SetupMovPlatform);
  93.     ignoreSp = NewSprite(0, 50, 200, &SetupMovPlatform);
  94.     ignoreSp = NewSprite(0, 200, 150, &SetupHMovPlatform);
  95.  
  96.     HideCursor();
  97.     while (!Button())
  98.     {
  99.         L = TickCount();
  100.         RunSAT(true);
  101.         while (L > TickCount() - 2L)
  102.             ;
  103.     }
  104.     ShowCursor();
  105.     SATSoundShutup();
  106. }
  107.