home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-21 | 5.1 KB | 202 lines | [TEXT/CWIE] |
- //===================================================================
- //======================= Headers =============================
-
- #include "AnimiWindow.h"
- #include "GameUtilities.h"
- #include "Screen.h"
-
- //===================================================================
- //======================= Globals =============================
-
- OffScreenBuff buff;
- rect pic[ 20 ];
-
- //===================================================================
- //======================= #define =============================
-
-
- //===================================================================
- //======================= Function Prototypes =====================
-
- void InitTHIng( void )
- {
- MySetRectWH( &pic[ 0 ] , 0 , 0 , 124 , 124 );
- MySetRectWH( &pic[ 1 ] , 124 , 0 , 124 , 124 );
- MySetRectWH( &pic[ 2 ] , 248 , 0 , 124 , 124 );
- MySetRectWH( &pic[ 3 ] , 372 , 0 , 124 , 124 );
- MySetRectWH( &pic[ 4 ] , 496 , 0 , 124 , 124 );
- MySetRectWH( &pic[ 5 ] , 620 , 0 , 124 , 124 );
-
- MySetRectWH( &pic[ 6 ] , 0 , 124 , 124 , 124 );
- MySetRectWH( &pic[ 7 ] , 124 , 124 , 124 , 124 );
- MySetRectWH( &pic[ 8 ] , 248 , 124 , 124 , 124 );
- MySetRectWH( &pic[ 9 ] , 372 , 124 , 124 , 124 );
- MySetRectWH( &pic[ 10 ] , 496 , 124 , 124 , 124 );
- MySetRectWH( &pic[ 11 ] , 620 , 124 , 124 , 124 );
-
- MySetRectWH( &pic[ 12 ] , 0 , 248 , 124 , 124 );
- MySetRectWH( &pic[ 13 ] , 124 , 248 , 124 , 124 );
-
- if( !buff.LoadPicBuff( 147 ) )
- SysBeep(0);
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: Constructor
-
- \----------------------------------------------------------------------------*/
- AnimiWindow :: AnimiWindow( void )
- {
- frame = 0;
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: Init
-
- \----------------------------------------------------------------------------*/
- Boolean AnimiWindow :: SetUp( short xLoc , short yLoc )
- {
- width = 124;
- height = 124;
-
- screenLoc.left = xLoc;
- screenLoc.top = yLoc;
- screenLoc.right = screenLoc.left + width;
- screenLoc.bottom = screenLoc.top + height;
-
- window.NewBuff( width , height );
-
- DrawPicture( &buff , &pic[ frame ] , &window , &window.GetBoundsSize() );
-
- return true;
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: HandleMouseClick
-
- \----------------------------------------------------------------------------*/
- void AnimiWindow :: HandleMouseClick( Boolean down , point where )
- {
- if( down )
- {
- draging = true;
- start = where;
- }
- else
- {
- if( draging )
- {
- screen.AddRectToUpdate( screenLoc );
-
- MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
-
- screen.AddRectToUpdate( screenLoc );
-
- draging = false;
- }
- }
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: HandleMouseMove
-
- \----------------------------------------------------------------------------*/
- void AnimiWindow :: HandleMouseMove( point where )
- {
- if( draging )
- {
- screen.AddRectToUpdate( screenLoc );
-
- MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
- start = where;
-
- screen.AddRectToUpdate( screenLoc );
- }
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: PointInWindow
-
- - just saids if the point it inside the window area or not
- \----------------------------------------------------------------------------*/
- Boolean AnimiWindow :: PointInWindow( point where )
- {
- return SectPtRect( where , screenLoc );
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: Active
-
- \----------------------------------------------------------------------------*/
- Boolean AnimiWindow :: Front( void )
- {
- return( front );
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: SetFront
-
- \----------------------------------------------------------------------------*/
- void AnimiWindow :: SetFront( Boolean f )
- {
- front = f;
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: DrawToScreen
-
- \----------------------------------------------------------------------------*/
- void AnimiWindow :: DrawToScreen( rect *where , Boolean backGround )
- {
- if( !backGround )
- {
- if( where == NULL )
- {
- screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
- NULL , 0 , 0 , 0 );
- }
- else
- {
- screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
- where , 0 , 0 , 0 );
- }
- }
- else
- {
- if( where == NULL )
- {
- screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
- NULL , kDrawTint , 16 , 0xffff );
- }
- else
- {
- screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
- where , kDrawTint , 16 , 0xffff );
- }
- }
-
- }
-
- /*----------------------------------------------------------------------------\
-
- AnimiWindow :: Animate
-
- \----------------------------------------------------------------------------*/
- void AnimiWindow :: Animate( void )
- {
- DrawPicture( &buff , &pic[ frame ] , &window , &window.GetBoundsSize() );
- screen.AddRectToUpdate( screenLoc );
-
- frame++;
-
- if( frame >= 13 )
- frame = 0;
- }