Darshan Nayak

Full Stack Developer

OpenGL Game - Player Modelling

Languages/Libraries: C++, OpenGL, glut

This application had player-modelling implemented into the same OpenGL game.

Game.cpp

Following code snippet shows the logging of some of the player parameters during gameplay.

						
//FUNCTION SNIPPET; NOT THE WHOLE CODE OF THE FUNCTION
void generateEndLogs()	//records various player/gameplay parameters
{
	//time between ring capture 
	ofstream file4;
	file4.open(fileNamePrefix + "_TimeBetweenPickupEachRing.csv");
	double nonZeroSumRingSeconds = 0.0;	//seconds; summation of only non-zero of 50 instances
	int nonZeroRingCount = 0;
	double sumRingSeconds = 0.0;			//seconds; summation of all 50 instances
	for (int i = 0; i < totalDisks; i++)
	{
		if (timeBetweenRingCaptureSeconds[i] != 0.0)
		{
			nonZeroSumRingSeconds += timeBetweenRingCaptureSeconds[i];
			nonZeroRingCount++;
		}
		sumRingSeconds += timeBetweenRingCaptureSeconds[i];
		file4 << "Ring[" + to_string(i) + "]" + "," + to_string(timeBetweenRingCaptureSeconds[i]) + "\n";	//Format: Ring[0],2.455 seconds
	}
	double nonZeroRingAverage;//consider only the rings that have been captured
	if (nonZeroRingCount != 0)
	{
		nonZeroRingAverage = nonZeroSumRingSeconds / nonZeroRingCount;//average time spent between ring capture for only nonZero rings
	}
	else
	{
		nonZeroRingAverage = 0.0;
	}
	double ringAverage = sumRingSeconds / totalDisks;	//average time spent between ring capture for all rings
	file4.close();
}