Make Your Own iPhone Game, Day 10


Conan finally kicks Skeletor’s ass!

A bit of the code to that determine’s if a character can attack another character (for example, if the player can attack an enemy):

-(BOOL) canAttack:(Character*)character
{
	CGFloat xDist = fabs(self.position.x - character.position.x);
	CGFloat yDist = fabs(self.position.y - character.position.y);

	return (((xDist * xDist) + (yDist * yDist)) < (attackDistance * attackDistance));
}

Leave a Reply

Spam protection by WP Captcha-Free

Storyteller   .:.   Musician   .:.   Vagabond   .:.   Wizard