示例#1
0
static void touch(Entity *other)
{
	if (self->target == NULL && other->type == PLAYER && other->health > 0)
	{
		setPlayerLocked(TRUE);

		setPlayerLocked(FALSE);

		self->target = other;

		self->thinkTime = 180;

		self->action = &raiseOffGround;

		self->y = self->target->y;

		self->targetX = self->x + self->w / 2 - player.w / 2;

		self->targetY = self->target->y - self->target->h;

		other->weight = 0;
	}

	else
	{
		entityTouch(other);
	}
}
示例#2
0
void updatePlayer(Input *input)
{
    /* On rajoute un timer au cas où notre héros mourrait
    Si le timer vaut 0, c'est que tout va bien, sinon, on le décrémente jusqu'à 0, et là,
    on réinitialise.
    C'est pour ça qu'on ne gère le joueur que si ce timer vaut 0. */
    if(player.timerMort == 0)
    {
        if(!player.touch) // S'il n'est pas touché
        {
            /* On gère le timer de l'invincibilité */
            if(player.invincibleTimer > 0) player.invincibleTimer--;

            /* On réinitialise notre vecteur de déplacement latéral (X), pour éviter que le perso
            ne fonce de plus en plus */
            player.dirX = player.dirY = player.isAttacking = 0;

            attackManagement(input, &player);

            if(player.state < ATTACK_HORIZONTAL && input->puched < 3) playerDir(input, &player);

            /* Si on n'appuie sur rien, on charge l'animation marquant l'inactivité (Idle), je n'ai pas regarder encore si je pouvais l'optimiser */
            playerIdle(input, &player);

            resetInput(input);
        }
        /* Sinon si il est touché */
        else if(player.touch)
            entityTouch();

        /* On rajoute notre fonction de détection des collisions qui va mettre à
        jour les coordonnées de notre héros. */
        mapCollision(&player);

        /* On gère le scrolling */
        centerScrollingOnPlayer();
    }



    /*Gestion de la mort. Si timerMort est différent de 0, c'est qu'il faut réinitialiser le joueur.
    On ignore alors ce qui précède et on joue cette boucle (un wait en fait) jusqu'à ce que
    timerMort == 1. A ce moment-là, on le décrémente encore -> il vaut 0 et on réinitialise
    le jeu avec notre bonne vieille fonction d'initialisation */
    if(player.timerMort > 0)
    {
        player.timerMort--;
        if(player.timerMort == 0)
        {
            changeLevel();
            initializePlayer(0);
        }
    }

}
示例#3
0
static void ramTouch(Entity *other)
{
	int health = player.health;

	entityTouch(other);

	if (player.health < health)
	{
		reactToHeadButtBlock(other);
	}
}
示例#4
0
static void touch(Entity *other)
{
	if (other->type == PLAYER && self->active == TRUE)
	{
		setInfoBoxMessage(0, 255, 255, 255, _("Press Action to interact"));
	}

	else
	{
		entityTouch(other);
	}
}
示例#5
0
static void touch(Entity *other)
{
	if (self->active == TRUE || self->health == 1)
	{
		entityTouch(other);
	}

	else
	{
		pushEntity(other);
	}
}
示例#6
0
static void touch(Entity *other)
{
	if (self->mental < 2 && strcmpignorecase(other->name, "item/spore") == 0)
	{
		other->inUse = FALSE;

		self->action = &becomeGreen;
	}

	else
	{
		entityTouch(other);
	}
}
示例#7
0
文件: chaos.c 项目: polluks/edgar
static void touch(Entity *other)
{
	if (game.cheating == TRUE && other->type == PLAYER && other->health > 0)
	{
		removeInventoryItemByObjectiveName("Amulet of Resurrection");

		other->die();
	}

	else
	{
		entityTouch(other);
	}
}
示例#8
0
static void touch(Entity *other)
{
	if (other->type == ITEM && strcmpignorecase(other->name, "item/repellent_spray") == 0)
	{
		self->face = self->x < other->x ? LEFT : RIGHT;

		self->dirX = (self->face == LEFT ? -self->speed : self->speed);
	}

	else
	{
		entityTouch(other);
	}
}
示例#9
0
static void touch(Entity *other)
{
	Entity *temp;

	if (!(self->flags & INVULNERABLE) && other->type == ITEM && strcmpignorecase(other->name, "item/repellent_spray") == 0)
	{
		self->mental++;

		if (self->mental == 50)
		{
			self->action = &shudder;

			self->targetX = self->x;

			self->thinkTime = 300;

			if (player.health > 0)
			{
				setInfoBoxMessage(180, 255, 255, 255, _("Now! Run while it's stunned!"));
			}

			self->health = 0;
		}

		else if (self->mental > 50)
		{
			self->thinkTime = 300;
		}

		setCustomAction(self, &invulnerableNoFlash, HIT_INVULNERABLE_TIME, 0, 0);
		setCustomAction(self, &flashWhite, 6, 0, 0);
	}

	else if (other->type == PLAYER && self->action == &attack)
	{
		temp = self;

		self = other;

		freeEntityList(playerGib());

		self = temp;
	}

	else
	{
		entityTouch(other);
	}
}
示例#10
0
文件: chaos.c 项目: polluks/edgar
static void eatTouch(Entity *other)
{
	if (other->type == PLAYER)
	{
		if (!(self->flags & GRABBING) && player.weight != 0)
		{
			self->flags |= GRABBING;
		}
	}

	else
	{
		entityTouch(other);
	}
}
示例#11
0
static void tongueTouch(Entity *other)
{
	if ((other->type == PLAYER || other->type == ENEMY) && self->target == NULL && other != self->head)
	{
		self->head->face = other->face;

		self->head->touch = &creeperTouch;

		self->target = other;

		self->target->flags |= FLY;

		self->thinkTime = 180;

		self->action = &moveToMouth;
	}

	else
	{
		entityTouch(other);
	}
}
示例#12
0
static void touch(Entity *other)
{
	if (self->startX == -1 && other->type == KEY_ITEM && strcmpignorecase(other->name, "item/stalactite") == 0)
	{
		self->takeDamage(other, 500);

		other->mental = -2;
	}

	else if (self->startX == 1 && self->endX == 1
		&& other->type == KEY_ITEM && strcmpignorecase(other->name, "item/ice_cube") == 0)
	{
		self->maxThinkTime--;

		setCustomAction(self, &flashWhite, 6, 0, 0);
		setCustomAction(self, &invulnerableNoFlash, HIT_INVULNERABLE_TIME, 0, 0);

		enemyPain();

		other->inUse = FALSE;

		if (self->maxThinkTime <= 0)
		{
			self->startX = -1;

			setEntityAnimation(self, "STUNNED");

			self->flags &= ~FLY;

			self->damage = 0;

			self->dirX = 0;

			self->dirY = 0;

			self->thinkTime = 600;

			self->action = &stunned;
		}
	}

	else if (self->startX == 1 && self->endX == 2
		&& other->type == PROJECTILE && strcmpignorecase(other->name, "weapon/flaming_arrow") == 0)
	{
		self->maxThinkTime--;

		setCustomAction(self, &flashWhite, 6, 0, 0);
		setCustomAction(self, &invulnerableNoFlash, HIT_INVULNERABLE_TIME, 0, 0);

		enemyPain();

		other->inUse = FALSE;

		if (self->maxThinkTime <= 0)
		{
			self->startX = -1;

			setEntityAnimation(self, "STUNNED");

			self->flags &= ~FLY;

			self->damage = 0;

			self->dirX = 0;

			self->dirY = 0;

			self->thinkTime = 600;

			self->action = &stunned;
		}
	}

	else
	{
		entityTouch(other);
	}
}