home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / SAT 2.3b4 / Demo ƒ / Collision demo ƒ / Collision.c < prev    next >
Encoding:
Text File  |  1995-01-16  |  1.3 KB  |  54 lines  |  [TEXT/KAHL]

  1.  
  2. //• C translation from Pascal source file: SATcollision.p
  3.  
  4. //• *****************************.
  5. //• ********* SAT Collision **********.
  6. //• *****************************.
  7.  
  8. //• A SAT demo that is slightly over SATminimal, demonstrating the simplest.
  9. //• collision handling based on the kind field (KindCollision)..
  10.  
  11. //• main SATcollision;
  12.  
  13. #include "SAT.h"
  14. #include "Collision.h"
  15. //, sMrEgghead, sApple;
  16.  
  17.  
  18. SpritePtr ignoreSp;
  19. long l;
  20. Point p;
  21.  
  22. main ()
  23. {
  24.     SATInitToolbox();
  25.  
  26. //• Initialize SAT.
  27.     SATConfigure(true, kVPositionSort, kKindCollision, 32);
  28.     SATInit(128, 129, 512, 322);
  29.  
  30. //• Initialize sprite units.
  31.     InitMrEgghead ();
  32.     InitApple ();
  33.  
  34. //• Make sprites.
  35.     GetMouse(&p); //• We get the mouse position in order to put Mr Egghead under it immediately.
  36.     ignoreSp = SATNewSprite(0, p.h, p.v, &SetupMrEgghead);
  37.     ignoreSp = SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), &SetupApple);
  38.  
  39.     HideCursor();
  40.  
  41.     do
  42.         {
  43.         l = TickCount ();
  44.         SATRun(true); //• Run a frame of animation.
  45.         while ( l > TickCount () - 3 ) //• Speed limit.
  46.             ;
  47.  
  48. //• Start a new apple once in a while.
  49.         if ( SATRand(40) == 1 )
  50.             ignoreSp = SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), &SetupApple);
  51.     } while (! Button ());
  52.     ShowCursor ();
  53.     SATSoundShutup (); //• Always make sure the sound channel is de-allocated!.
  54. }