home *** CD-ROM | disk | FTP | other *** search
- #include "bullet.h"
- #include "gfx.h"
- #include "global.h"
- #include "messages.h"
-
- Bullet::Bullet()
- {
- loc.x=loc.y=0;
- }
-
- void Bullet::initialize()
- {
- load_gfxlib( "ss.gfx" );
- }
-
- boolean Bullet::Move(void)
- {
- if ( !active )
- return FALSE;
-
- // movement step
- const int MoveLength=8;
-
- if ( loc.y>190 )
- return FALSE;
- else
- loc.y+=MoveLength;
-
- if ( CheckForCollision() )
- {
- active=NO;
- MsgInt=5;
- post_message( StealthHit, 0 );
- }
-
- return TRUE;
- }
-
- boolean Bullet::CheckForCollision()
- {
- rect MyPos={loc.x,loc.y,loc.x+6,loc.y+7,6,7};
- // 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 Bullet::OnDraw(void)
- {
- show_image( loc.x, loc.y, BULLET );
- }