home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / thx / demos / skyscrap / build / amscrolr.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-13  |  1.5 KB  |  61 lines

  1. #include "amscrolr.h"
  2. #include "gfx.h"
  3.  
  4. int TerrainList[]=
  5. {
  6.   TERRAIN1, TERRAIN2, TERRAIN3, TERRAIN4, TERRAIN5, TERRAIN6, TERRAIN7,
  7.   TERRAIN8, TERRAIN9, TERRAIN10, TERRAIN11, TERRAIN12, TERRAIN13, TERRAIN14
  8. };
  9.  
  10. AlphaMissionScroller::AlphaMissionScroller()
  11. {
  12.   wrap=wrapping=NO;
  13.   WrapY=0;
  14.   SetPixelIncrement( 2 );
  15.   SetWorldWidthHeight( 320, 2800 );
  16.   SetScreenWidthHeight( 320, 200 );
  17.   SetImageWidthHeight( 320, 200 );
  18.   SetAtSouthMost();
  19.   image=TerrainList;
  20.   NumImages=14;
  21. }
  22.  
  23. void AlphaMissionScroller::initialize()
  24. {
  25.   load_gfxlib( "ss.gfx" );
  26. }
  27.  
  28. void AlphaMissionScroller::draw(void)
  29. {
  30.   if ( AtMost( NORTH )==YES && wrapping==NO )
  31.     wrapping=YES, WrapY=PixelIncrement;
  32.   if ( wrapping )
  33.   {
  34.     show_clipped_image( 0, -(ScreenHeight-WrapY), image[NumImages-1] );
  35.     show_clipped_image( 0, WrapY, image[0] );
  36.     WrapY+=PixelIncrement;
  37.     if ( WrapY>=ScreenHeight )
  38.     {
  39.       wrapping=NO;
  40.       y=WorldHeight-ScreenHeight;
  41.     }
  42.   }
  43.   else
  44.   {
  45.     // figure the index to the image
  46.     int yIndex=y/ImageHeight;
  47.     // figure the remainder of pixels
  48.     int yRemainder=y%ImageHeight;
  49.     // figure number of images to draw
  50.     int vImages=(ScreenHeight+yRemainder)/ImageHeight;
  51.     vImages+=((ScreenHeight+yRemainder)%ImageHeight)!=0 ? 1:0;
  52.     // draw them
  53.     int dy=0-yRemainder;
  54.     for( int i=0; i<vImages; i++ )
  55.     {
  56.       show_clipped_image( 0, dy, image[yIndex+i] );
  57.       dy+=ImageHeight;
  58.     }
  59.   }
  60. }
  61.