Esempio n. 1
0
void CGpApp::PlayerDead()
{
	m_PlayerStatus = PLAYER_STATUS_DEAD;

	if(m_Player.nAlive <= 0)
		return;

	PlayerRevive();
}
Esempio n. 2
0
void GameDoLogic(bool* Continue, bool* Error, Uint32 Milliseconds)
{
	(void)Continue;
	(void)Error;
	if (Pause) return;

	cpSpaceStep(space.Space, Milliseconds * 0.001);
	CameraUpdate(&camera, PlayerMiddleY(), Milliseconds);

	bool hasPlayers = false;
	for (int i = 0; i < MAX_PLAYERS; i++)
	{
		Player *p = &players[i];
		if (!p->Enabled) continue;
		PlayerUpdate(p, Milliseconds);
		// Check if the player needs to be respawned
		if (p->RespawnCounter == 0 && !p->Alive && space.Gaps.size > 0)
		{
			SpaceRespawnPlayer(&space, p);
		}
		if (!p->Alive)
		{
			// Check if any players are past ones that await reenabling
			if (p->RespawnCounter == -1 && PlayerMinY() < p->y)
			{
				PlayerRevive(p);
			}
			else
			{
				continue;
			}
		}
		hasPlayers = true;

		// Check player pickups
		if (PickupsCollide(p->x, p->y, PLAYER_RADIUS))
		{
			PlayerScore(p, false);
		}

		// Players that hit the top of the screen die
		if (cpBodyGetPosition(p->Body).y + PLAYER_RADIUS >=
			camera.Y + FIELD_HEIGHT / 2)
		{
			PlayerKill(p);
		}
	}
	// If no players left alive, end the game
	if (!hasPlayers)
	{
		ToTitleScreen(false);
	}
	SpaceUpdate(&space, PlayerMinY(), camera.Y, PlayerMaxY(), &players[0]);

	ParticlesUpdate(Milliseconds);

	// Players that hit the top of the screen die
	if (PlayerMaxY() + PLAYER_RADIUS >= camera.Y + FIELD_HEIGHT / 2)
	{
		ToTitleScreen(false);
	}
}