
#import <libc.h>
#import "NXIBullet.h"
#import "NXIGameBrain.h"
#import "NXIPlayer.h"


@implementation NXIBullet

- init
{
	id ret = [super init];
	renderedImage = [NXImage findImageNamed:"Bullet.tiff"];
	NX_HEIGHT(&boundingBox) = BULLET_WIDTH;
	NX_WIDTH(&boundingBox) = BULLET_HEIGHT;
	maxFrames[0] = BULLET_FRAMES;
	return ret;
}

- collidedWith:anActor	// called when it is detected that we hit something
{
	// ***** need to remove us from the stage if hit Player, base,
	// or one of the player's bullets
	return self;
}

- move:sender		// move one frame
{
	if (state == BULLET_INACTIVE) return self;
	GK_VECTOR_Y(&nextLocation) -= BULLET_DROP_SPEED;
	// all collisions are handles by collision detection machinery
	if (GK_VECTOR_Y(&nextLocation) <= -BULLET_HEIGHT) {
		// take bullet off of screen
		state = BULLET_INACTIVE;
		[self leaveTheStage];
	}
	return self;
}

@end
