Beispiel #1
0
bool LuaState::DoFile(const char* path)
{
    DDFile file(path);
    file.LoadFileIntoBuffer();
    return DoBuffer(path, file.Buffer(), file.Size());
}
Beispiel #2
0
void DrawScreen(struct Buffer *b, TActor * player1, TActor * player2)
{
	static int x = 0;
	static int y = 0;
	int xNoise, yNoise;

	if (screenShaking) {
		xNoise = rand() & 7;
		yNoise = rand() & 7;
	} else
		xNoise = yNoise = 0;

	if (player1 && player2) {
		if (abs(player1->tileItem.x - player2->tileItem.x) < gOptions.xSplit
		    && abs(player1->tileItem.y - player2->tileItem.y) < gOptions.ySplit) {
			SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
			// One screen
			x = (player1->tileItem.x +
			     player2->tileItem.x) / 2;
			y = (player1->tileItem.y +
			     player2->tileItem.y) / 2;

			SetBuffer(x + xNoise, y + yNoise, b, X_TILES);
			if (fLOS) {
				LineOfSight(player1->tileItem.x,
					    player1->tileItem.y, b,
					    IS_SHADOW);
				LineOfSight(player2->tileItem.x,
					    player2->tileItem.y, b,
					    IS_SHADOW2);
				FixBuffer(b, IS_SHADOW | IS_SHADOW2);
			}
			DrawBuffer(b, 0);
		} else {
			SetClip(0, 0, (SCREEN_WIDTH / 2) - 1, SCREEN_HEIGHT - 1);
			DoBuffer(b, player1->tileItem.x, player1->tileItem.y, 0, X_TILES_HALF, xNoise, yNoise);
			SetLeftEar(player1->tileItem.x, player1->tileItem.y);
			SetClip((SCREEN_WIDTH / 2) + 1, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
			DoBuffer(b, player2->tileItem.x, player2->tileItem.y, (SCREEN_WIDTH / 2) + 1, X_TILES_HALF, xNoise, yNoise);
			SetRightEar(player2->tileItem.x, player2->tileItem.y);
			x = player1->tileItem.x;
			y = player1->tileItem.y;
			BlackLine();
		}
	} else if (player1) {
		SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
		DoBuffer(b, player1->tileItem.x, player1->tileItem.y, 0,
			 X_TILES, xNoise, yNoise);
		SetLeftEar(player1->tileItem.x, player1->tileItem.y);
		SetRightEar(player1->tileItem.x, player1->tileItem.y);
		x = player1->tileItem.x;
		y = player1->tileItem.y;
	} else if (player2) {
		SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
		DoBuffer(b, player2->tileItem.x, player2->tileItem.y, 0,
			 X_TILES, xNoise, yNoise);
		SetLeftEar(player2->tileItem.x, player2->tileItem.y);
		SetRightEar(player2->tileItem.x, player2->tileItem.y);
		x = player2->tileItem.x;
		y = player2->tileItem.y;
	} else
		DoBuffer(b, x, y, 0, X_TILES, xNoise, yNoise);
	SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
}
Beispiel #3
0
void CameraDraw(
	Camera *camera, const input_device_e pausingDevice,
	const bool controllerUnplugged)
{
	Vec2i centerOffset = Vec2iZero();
	const int numLocalPlayersAlive =
		GetNumPlayers(PLAYER_ALIVE_OR_DYING, false, true);
	const int numLocalPlayers = GetNumPlayers(PLAYER_ANY, false, true);
	const int w = gGraphicsDevice.cachedConfig.Res.x;
	const int h = gGraphicsDevice.cachedConfig.Res.y;

	for (int i = 0; i < GraphicsGetScreenSize(&gGraphicsDevice.cachedConfig); i++)
	{
		gGraphicsDevice.buf[i] = COLOR2PIXEL(colorBlack);
	}

	const Vec2i noise = ScreenShakeGetDelta(camera->shake);

	GraphicsResetBlitClip(&gGraphicsDevice);
	if (numLocalPlayersAlive == 0)
	{
		// Count the number of local players with lives left
		// If there are none, then try to spectate if there are remote players
		int firstRemotePlayerUID = -1;
		bool hasLocalPlayerLives = false;
		CA_FOREACH(const PlayerData, p, gPlayerDatas)
			if (p->Lives > 0)
			{
				if (p->IsLocal)
				{
					hasLocalPlayerLives = true;
					break;
				}
				else
				{
					firstRemotePlayerUID = p->UID;
				}
			}
		CA_FOREACH_END()
		if (!hasLocalPlayerLives)
		{
			if (camera->spectateMode == SPECTATE_NONE)
			{
				// Enter spectator mode
				// If there are remote players, follow them
				if (firstRemotePlayerUID != -1)
				{
					camera->spectateMode = SPECTATE_FOLLOW;
					camera->FollowPlayerUID = firstRemotePlayerUID;
				}
				else
				{
					// Free-look mode
					camera->spectateMode = SPECTATE_FREE;
				}
			}
		}
		else
		{
			// Don't spectate
			camera->spectateMode = SPECTATE_NONE;
		}
		if (camera->spectateMode == SPECTATE_FOLLOW)
		{
			FollowPlayer(&camera->lastPosition, camera->FollowPlayerUID);
		}
		DoBuffer(
			&camera->Buffer,
			camera->lastPosition,
			X_TILES, noise, centerOffset);
		SoundSetEars(camera->lastPosition);
	}