home *** CD-ROM | disk | FTP | other *** search
- #include "rocket.h"
- #include "gfx.h"
- #include "global.h"
- #include "messages.h"
-
- Rocket::Rocket()
- {
- loc.x=loc.y=0;
- }
-
- void Rocket::initialize()
- {
- load_gfxlib( "ss.gfx" );
- }
-
- void Rocket::Reset(void)
- {
- width=get_image_width( ROCKET );
- height=get_image_height( ROCKET );
- }
-
- boolean Rocket::Move(void)
- {
- if ( !active )
- return FALSE;
-
- // movement step
- const int MoveLength=8;
-
- if ( loc.y>180 )
- return FALSE;
- else
- loc.y+=MoveLength;
-
- if ( CheckForCollision() )
- {
- active=NO;
- MsgInt=20;
- post_message( StealthHit, 0 );
- }
-
- return TRUE;
- }
-
- boolean Rocket::CheckForCollision()
- {
- rect MyPos={loc.x,loc.y,loc.x+width,loc.y+15,width,height};
- // check to see if I hit the stealth
- if ( MyPos.b<StealthRect.t || MyPos.t>StealthRect.b )
- return NO;
- else
- {
- if ( MyPos.r<StealthRect.l || MyPos.l>StealthRect.r )
- return NO;
- else
- return YES;
- }
- }
-
- void Rocket::OnDraw(void)
- {
- show_image( loc.x, loc.y, ROCKET );
- }