コード例 #1
0
ファイル: tuning_fork.c プロジェクト: revcozmo/edgar
static void activate(int val)
{
	EntityList *el, *entities;
	Entity *temp;

	entities = getEntities();

	if (game.status == IN_GAME)
	{
		playSoundToMap("sound/item/tuning_fork", EDGAR_CHANNEL, self->x, self->y, 0);

		for (el=entities->next;el!=NULL;el=el->next)
		{
			if (el->entity->inUse == TRUE)
			{
				if ((strcmpignorecase(el->entity->requires, "TUNING_FORK") == 0 && getDistanceFromPlayer(el->entity) < 128)
					|| (strcmpignorecase(el->entity->requires, "BOSS_TUNING_FORK") == 0))
				{
					temp = self;

					self = el->entity;

					self->activate(100);

					self = temp;
				}
			}
		}
	}
}
コード例 #2
0
ファイル: large_book.c プロジェクト: LibreGames/edgar
static void followPlayer()
{
	self->targetX = player.x - self->w / 2 + player.w / 2;

	/* Position above the player */

	if (getDistanceFromPlayer(self) > SCREEN_WIDTH)
	{
		self->dirX = 0;

		hover();
	}

	else if (abs(self->x - self->targetX) <= abs(self->dirX))
	{
		self->x = self->targetX;

		self->dirX = 0;

		self->thinkTime = 15;

		if (player.health > 0)
		{
			self->action = &dropOnPlayer;
		}

		else
		{
			hover();
		}
	}

	else
	{
		self->dirX = self->targetX < self->x ? -player.speed * 3 : player.speed * 3;
	}

	checkToMap(self);
}