home *** CD-ROM | disk | FTP | other *** search
- #include "plasma.h"
- #include "gfx.h"
- #include "messages.h"
- #include "global.h"
-
- Plasma::Plasma()
- {
- loc.x=loc.y=0;
- }
-
- void Plasma::initialize()
- {
- load_gfxlib( "ss.gfx" );
- }
-
- void Plasma::Reset(void)
- {
- width=get_image_width( PLASMA );
- height=get_image_height( PLASMA );
- }
-
- boolean Plasma::Move(void)
- {
- if ( !active )
- return FALSE;
-
- // movement step
- const int MoveLength=8;
-
- if ( loc.y<=0 )
- return FALSE;
- else
- loc.y-=MoveLength;
-
- if ( CheckForHeliCollision() )
- {
- active=NO;
- post_message( HelicopterHit );
- }
- if ( CheckForF15Collision() )
- {
- active=NO;
- post_message( F15Hit );
- }
-
- return TRUE;
- }
-
- boolean Plasma::CheckForHeliCollision(void)
- {
- rect MyPos={loc.x,loc.y,loc.x+width,loc.y+height,width,height};
- // check to see if I hit the helicopter
- if ( MyPos.b<HelicopterRect.t || MyPos.t>HelicopterRect.b )
- return NO;
- else
- {
- if ( MyPos.r<HelicopterRect.l || MyPos.l>HelicopterRect.r )
- return NO;
- else
- return YES;
- }
- }
-
- boolean Plasma::CheckForF15Collision(void)
- {
- rect MyPos={loc.x,loc.y,loc.x+width,loc.y+height,width,height};
- // check to see if I hit the F15
- if ( MyPos.b<F15Rect.t || MyPos.t>F15Rect.b )
- return NO;
- else
- {
- if ( MyPos.r<F15Rect.l || MyPos.l>F15Rect.r )
- return NO;
- else
- return YES;
- }
- }
-
- void Plasma::OnDraw(void)
- {
- show_image( loc.x, loc.y, PLASMA );
- }