home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / examples / ex3 / example3.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-05  |  1.1 KB  |  64 lines

  1. #include <Resolution.h>
  2. #include <Screen.h>
  3. #include <BlockMap.h>
  4. #include <DoubleBuffer.h>
  5. #include <Joystick.h>
  6. #include <Shape.h>
  7.  
  8. const int MAPSIZE=64;
  9. const int NUMBLOCKS=32;
  10.  
  11. void Animate(BlockMap& Map, BlockImages& Images)
  12. {
  13.     BlockMapView View(Map,Images,0,0,9,9);
  14.     Joystick Stick;
  15.     Rectangle Range(0,0,MAPSIZE-9+1,MAPSIZE-9+1);
  16.     Point P(3,3);
  17.  
  18.     while (!Stick.Trigger()) {
  19.         P.x+=Stick.X();
  20.         P.y+=Stick.Y();
  21.         P.Bound(Range);
  22.  
  23.         View.Views(P);
  24.  
  25.         View.Draw();
  26.         Pages->Flip();
  27.     }
  28. }
  29.  
  30. main()
  31. {
  32.     Resolution InitialRez;
  33.  
  34.     if (InitialRez!=STHigh && InitialRez!=TTMedium)
  35.         STLow.Use();
  36.  
  37.     Pages=new DoubleBuffer;
  38.  
  39.     Pages->Current().Clear();
  40.     Pages->NowShowing().Clear();
  41.  
  42.     Screen ImageBank(STLow);
  43.     BlockMap Map(MAPSIZE,MAPSIZE);
  44.     BlockImages* Images;
  45.  
  46.     for (int x=0; x<MAPSIZE; x++)
  47.         for (int y=0; y<MAPSIZE; y++) {
  48.             Map.Set(x,y,(x+y)%NUMBLOCKS);
  49.         }
  50.  
  51.     if (InitialRez==STHigh) {
  52.         ImageBank.Load("example3.ca3");
  53.         Images=new WideMonochromeBlockImages(NUMBLOCKS,30);
  54.     } else {
  55.         ImageBank.Load("example3.ca1");
  56.         Images=new ColourBlockImages(NUMBLOCKS,15);
  57.     }
  58.  
  59.     Images->GetImages(0,NUMBLOCKS,ImageBank);
  60.     ImageBank.ShowPalette();
  61.  
  62.     Animate(Map,*Images);
  63. }
  64.