示例#1
0
// loads the BrogueHighScores.txt file into the scoreBuffer global variable
// score file format is: score, tab, date in seconds, tab, description, newline.
short loadScoreBuffer() {
	short i;
	FILE *scoresFile;
	time_t rawtime;
	struct tm * timeinfo;
	
	scoresFile = fopen("BrogueHighScores.txt", "r");
	
	if (scoresFile == NULL) {
		initScores();
		scoresFile = fopen("BrogueHighScores.txt", "r");
	}
	
	for (i=0; i<HIGH_SCORES_COUNT; i++) {
		// load score and also the date in seconds
		fscanf(scoresFile, "%li\t%li\t", &(scoreBuffer[i].score), &(scoreBuffer[i].dateNumber));
		
		// load description
		fgets(scoreBuffer[i].description, COLS, scoresFile);
		// strip the newline off the end
		scoreBuffer[i].description[strlen(scoreBuffer[i].description) - 1] = '\0';
		
		// convert date to mm/dd/yy format
		rawtime = (time_t) scoreBuffer[i].dateNumber;
		timeinfo = localtime(&rawtime);
		strftime(scoreBuffer[i].dateText, DCOLS, "%m/%d/%y", timeinfo);
	}
	fclose(scoresFile);
	return sortScoreBuffer();
}
示例#2
0
int main(int argc, char **argv)
{
    /*Initialize and create window.*/
    glutInit(&argc, argv);
    glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    global.windowID = glutCreateWindow("Assignment 2 - s3331571");

    /*Load images to be 'transformed' into textures.*/
    globalTexture.grass = loadImage("./Texture/grass.jpg");
    globalTexture.metal = loadImage("./Texture/metal.jpg");
    
    /*Load textures from the images.*/
    globalTexture.grassT = loadTexture(globalTexture.grass);
    globalTexture.metalT = loadTexture(globalTexture.metal);
    glEnable(GL_TEXTURE_2D);

    /*Initialize any variables.*/
    initVariables();
    initFiringVariables();
    initPlayerBases();
    initScores();
   
    glEnable(GL_DEPTH_TEST);
    
    /*Call helper method to initilize lighting.*/
    initLighting();   

    /*Setup Callbacks.*/
    glutDisplayFunc(display);
    glutMotionFunc(mouseMove);
    //glutMouseFunc(mouse);
    glutKeyboardFunc(keyboard);
    glutSpecialFunc(keyboardSpecial);
    glutIdleFunc(idle);
    
    /*Give random function a seed.*/
    srand(time(NULL));

    /*Calculate initial vertices.*/
    storeStarBackground();
    calcGeometryVertices();
    
    setupAllMusic();

    glutMainLoop();
}