Exemplo n.º 1
0
void HUDDraw(HUD *hud, const input_device_e pausingDevice)
{
	char s[50];
	int flags = 0;
	const int numPlayersAlive =
		GetNumPlayers(PLAYER_ALIVE_OR_DYING, false, false);
	const int numLocalPlayers = GetNumPlayers(PLAYER_ANY, false, true);
	const int numLocalPlayersAlive =
		GetNumPlayers(PLAYER_ALIVE_OR_DYING, false, true);

	Rect2i r;
	r.Size = Vec2iNew(
		hud->device->cachedConfig.Res.x,
		hud->device->cachedConfig.Res.y);
	if (numLocalPlayersAlive <= 1)
	{
		flags = 0;
	}
	else if (
		ConfigGetEnum(&gConfig, "Interface.Splitscreen") == SPLITSCREEN_NEVER)
	{
		flags |= HUDFLAGS_SHARE_SCREEN;
	}
	else if (numLocalPlayers == 2)
	{
		r.Size.x /= 2;
		flags |= HUDFLAGS_HALF_SCREEN;
	}
	else if (numLocalPlayers == 3 || numLocalPlayers == 4)
	{
		r.Size.x /= 2;
		r.Size.y /= 2;
		flags |= HUDFLAGS_QUARTER_SCREEN;
	}
	else
	{
		assert(0 && "not implemented");
	}

	int idx = 0;
	for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++)
	{
		const PlayerData *p = CArrayGet(&gPlayerDatas, i);
		if (!p->IsLocal)
		{
			idx--;
			continue;
		}
		int drawFlags = flags;
		r.Pos = Vec2iZero();
		if (idx & 1)
		{
			r.Pos.x = r.Size.x;
			drawFlags |= HUDFLAGS_PLACE_RIGHT;
		}
		if (idx >= 2)
		{
			r.Pos.y = r.Size.y;
			drawFlags |= HUDFLAGS_PLACE_BOTTOM;
		}
		TActor *player = NULL;
		if (IsPlayerAlive(p))
		{
			player = ActorGetByUID(p->ActorUID);
		}
		DrawPlayerStatus(hud, p, player, drawFlags, r);
		DrawScoreUpdate(&hud->scoreUpdates[idx], drawFlags);
		DrawHealthUpdate(&hud->healthUpdates[idx], drawFlags);
		DrawAmmoUpdate(&hud->ammoUpdates[idx], drawFlags);
	}
	// Only draw radar once if shared
	if (ConfigGetBool(&gConfig, "Interface.ShowHUDMap") &&
		(flags & HUDFLAGS_SHARE_SCREEN) &&
		IsAutoMapEnabled(gCampaign.Entry.Mode))
	{
		DrawSharedRadar(hud->device, RADAR_SCALE, hud->showExit);
	}

	if (numPlayersAlive == 0)
	{
		if (AreAllPlayersDeadAndNoLives())
		{
			if (!IsPVP(gCampaign.Entry.Mode))
			{
				FontStrCenter("Game Over!");
			}
			else
			{
				FontStrCenter("All Kill!");
			}
		}
	}
	else if (hud->mission->state == MISSION_STATE_PICKUP)
	{
		int timeLeft = gMission.pickupTime + PICKUP_LIMIT - gMission.time;
		sprintf(s, "Pickup in %d seconds\n",
			(timeLeft + (FPS_FRAMELIMIT - 1)) / FPS_FRAMELIMIT);
		FontStrCenter(s);
	}

	if (pausingDevice != INPUT_DEVICE_UNSET)
	{
		Vec2i pos = Vec2iScaleDiv(Vec2iMinus(
			gGraphicsDevice.cachedConfig.Res,
			FontStrSize("Foo\nPress foo or bar to unpause\nBaz")), 2);
		const int x = pos.x;
		FontStr("<Paused>", pos);

		pos.y += FontH();
		pos = FontStr("Press ", pos);
		color_t c = colorWhite;
		const char *buttonName =
			InputGetButtonNameColor(pausingDevice, 0, CMD_ESC, &c);
		pos = FontStrMask(buttonName, pos, c);
		FontStr(" again to quit", pos);

		pos.x = x;
		pos.y += FontH();
		pos = FontStr("Press ", pos);
		buttonName = InputGetButtonNameColor(
			pausingDevice, 0, CMD_BUTTON1, &c);
		pos = FontStrMask(buttonName, pos, c);
		pos = FontStr(" or ", pos);
		buttonName = InputGetButtonNameColor(
			pausingDevice, 0, CMD_BUTTON2, &c);
		pos = FontStrMask(buttonName, pos, c);
		FontStr(" to unpause", pos);
	}

	if (hud->messageTicks > 0 || hud->messageTicks == -1)
	{
		// Draw the message centered, and just below the automap
		Vec2i pos = Vec2iNew(
			(hud->device->cachedConfig.Res.x -
			FontStrW(hud->message)) / 2,
			AUTOMAP_SIZE + AUTOMAP_PADDING + AUTOMAP_PADDING);
		FontStrMask(hud->message, pos, colorCyan);
	}

	if (ConfigGetBool(&gConfig, "Interface.ShowFPS"))
	{
		FPSCounterDraw(&hud->fpsCounter);
	}
	if (ConfigGetBool(&gConfig, "Interface.ShowTime"))
	{
		WallClockDraw(&hud->clock);
	}

	DrawKeycards(hud);

	// Draw elapsed mission time as MM:SS
	int missionTimeSeconds = gMission.time / FPS_FRAMELIMIT;
	sprintf(s, "%d:%02d",
		missionTimeSeconds / 60, missionTimeSeconds % 60);

	FontOpts opts = FontOptsNew();
	opts.HAlign = ALIGN_CENTER;
	opts.Area = hud->device->cachedConfig.Res;
	opts.Pad.y = 5;
	FontStrOpt(s, Vec2iZero(), opts);

	if (HasObjectives(gCampaign.Entry.Mode))
	{
		DrawObjectiveCounts(hud);
	}
}
Exemplo n.º 2
0
void DIY_Level::LoadContent()
{
	//Delete old main camera and set currentCamera to it.
	mainCamera->isFlagged = true;
	mainCamera = new GameCamera(this, Vec3(0, 0.75f, -7), Vec3::Zero());
	currentCamera = mainCamera;

	//ADD GUI  **MUST BE BEFORE OTHER TEXTURES OR IT WON'T SHOW UP** <- for some reason...
	gui = new DIY_Level_GUI(this, par, HasObjectives());

	Models->CreateSkybox("skybox", 10000.0f);
	Models->loadTexture("skybox1", "Images/skyboxUP.png");
	Models->loadTexture("layerGrid", "Images/grid.png");

	Models->loadTexture("planet1", "Images/aruba.tif");
	Models->loadTexture("planet2", "Images/planet_Rim.tif");
	Models->loadTexture("planet3", "Images/minersMoon.tif");
	Models->loadTexture("planet4", "Images/planetTex.png");
	Models->loadTexture("planet5", "Images/hoth.tif");

	Models->loadTexture("ballSkin", "Images/8ball.png");
	Models->loadModel("sphere", "Models/planet.obj", true);
	Models->loadModel("sun", "Models/turboSphere.obj", true);

	Models->loadModel("warpGate", "Models/WarpGate.obj", true);
	Models->loadTexture("gateTexture", "Images/rosary.png");

	Models->loadTexture("meteorTex1", "Images/meteor_texture.tif");
	Models->loadTexture("meteorTex2", "Images/meteor_texture_2.tif");
	Models->loadTexture("meteorTex3", "Images/meteor_texture_3.tif");

	Models->loadTexture("sunTexture", "Images/sun.tif");

	Models->loadModel("meteor1", "Models/meteor_01.obj", true);
	Models->loadModel("meteor2", "Models/meteor_02.obj", true);
	Models->loadModel("meteor3", "Models/meteor_03.obj", true);

	//Load up and play the music for in-game
	Audio->loadMusic("gameTheme", "Sounds/Exotics.wav");
	//Audio->getMusic("gameTheme")->Play();

	Models->loadModel("wormhole", "Models/wormhole.obj", true);
	Models->loadTexture("wormholeTexture", "Images/Galaxy.png");

	//Gotta be big to show up..
	//don't know why 
	const int texSize = 14 * 14 * 4;
	float pixelDataWhite[texSize];
	for (int i = 0; i < texSize; i++)
	{
		pixelDataWhite[i] = 1.0f;
	}
	Models->createTexture("white", pixelDataWhite, 1, 1);
	//Models->loadModel("pointer", "Models/Hand_Pointer.obj", true);
	Models->loadModel("pointer", "Models/pointer.obj", true);


	//Setting level boundaries. CAN BE EDITTED
	levelBoundsX = 10;

	LoadLevel();

	gui->SetObjectivesRemaining(1);
	gui->SetLevelPar(par);

	//Change camera to new focus camera
	mainCamera->isFlagged = true;
	mainCamera = new FocusCamera(this, playerBall, playerBall->position + Vec3(0, 0, -7));
	currentCamera = mainCamera;


	//Can now go through Update loop.
	hasFinishedLoading = true;
}