bool fireball::initialize(Game *gamePtr, TextureManager *textureM)
{
	Entity::initialize(gamePtr, fireballNS::WIDTH, fireballNS::HEIGHT, fireballNS::COLUMNS, textureM);
	setFrames(fireballNS::START_FRAME, fireballNS::END_FRAME);
	setCurrentFrame(fireballNS::START_FRAME);
	setFrameDelay(fireballNS::ANIMATION_DELAY);
	setVelocity({ fireballNS::SPEED, 0 });
	setEdge(fireballNS::FIREBALL_EDGE);
	return true;
}
Example #2
0
void Boxer::animate(float frameTime) {
	if(input->isKeyDown(VK_RIGHT) || input->isKeyDown(VK_LEFT)){
		isWalking = false;
	}
	else{
		isWalking = true;
	}
	if (isAttacking) {
		setFrameDelay(0.05);
		setFrames(12, 23);
		if (currentFrame == endFrame) isAttacking = false;
		else return;
	}
	if (isWalking) {
		setFrameDelay(0.1);
		setFrames(6, 11);
		flipHorizontal(!facingRight);
	} else {
		setFrameDelay(0.075);
		setFrames(0, 5);
		flipHorizontal(!facingRight);
	}
}
void Goblin::senseDistance(int wallX, int level){
	// +50 lets it overlap castle a bit, for some depth
	float distance = spriteData.x + 50 - wallX;
	float maxDistance = GAME_WIDTH - wallX + 50;

	// change speed based on distance from wall and framedelay
	// if at tower do not execute large if else if
	if(distance > 0){
		if(distance/maxDistance < .1) {
			velocity.x = -goblinNS::SPEED - 45;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_9);
		}
		else if(distance/maxDistance < .2) {
			velocity.x = -goblinNS::SPEED - 40;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_8);
		}
		else if(distance/maxDistance < .3) {
			velocity.x = -goblinNS::SPEED - 35;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_7);
		}
		else if(distance/maxDistance < .4) {
			velocity.x = -goblinNS::SPEED - 30;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_6);
		}
		else if(distance/maxDistance < .5){
			velocity.x = -goblinNS::SPEED - 25;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_5);
		}
		else if(distance/maxDistance < .6) {
			velocity.x = -goblinNS::SPEED - 20;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_4);
		}
		else if(distance/maxDistance < .7) {
			velocity.x = -goblinNS::SPEED - 15;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_3);
		}
		else if(distance/maxDistance < .8) {
			velocity.x = -goblinNS::SPEED - 10;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_2);
		}
		else {
			velocity.x = -goblinNS::SPEED - 5;
			setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_1);
		}
	}
	else {
		velocity.x = 0;
		setFrames(goblinNS::ATTACK_START_FRAME, goblinNS::ATTACK_END_FRAME);		
		setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY);
	}
	velocity.x *= level * 0.85;
	//velocity.x *= .15;
	setFrameDelay(getFrameDelay() / level);
}