Пример #1
0
void updateUI(void){
    if (currentMenuID == 0 || currentMenuID == 1)
		drawSleep();		
		
	else if (currentMenuID == 10){
		cellsPerFrame = 4;
		drawMainMenu();
	}		
	
	else if (currentMenuID == 11){
		cellsPerFrame = 4;
		drawInavlidResearchPeriod();
	}
		
    else if (currentMenuID == 20 || currentMenuID == 44 || currentMenuID == 54){
		cellsPerFrame = 4;
		drawChooseActivity();
	}		
		
	else if (currentMenuID == 21 || currentMenuID == 45 || currentMenuID == 56){
		cellsPerFrame = 4;
		drawChooseMood();
	}		
		
	else if (currentMenuID == 22 || currentMenuID == 46 || currentMenuID == 55 || currentMenuID == 57 || currentMenuID == 61){
		cellsPerFrame = 4;
		if(currentMenuID == 22)
			drawLogConfirm(LOG);
		else if(currentMenuID == 46)
			drawLogConfirm(ADD);
		else if(currentMenuID == 55 || currentMenuID == 57)
			drawLogConfirm(EDIT);
		else if(currentMenuID == 61)
			drawLogConfirm(REMOVE);
	}		
		
    else if (currentMenuID == 30){
		cellsPerFrame = 2;
		drawTimeline();
	}		
		
    else if (currentMenuID == 40){
		cellsPerFrame = 4;
		drawModifyMenu();
	}
    else if (currentMenuID == 41 || currentMenuID == 50 ||  currentMenuID == 60){
		cellsPerFrame = 2;
		if(currentMenuID == 41)
			drawModifyTimeslot(ADD);
		else if(currentMenuID == 50)
			drawModifyTimeslot(EDIT);
		else if(currentMenuID == 60)
			drawModifyTimeslot(REMOVE);
	}		
		
	else if (currentMenuID == 42 || currentMenuID == 52){
		drawChooseStartTime();
		manipulateTime = NEUTRAL;
	}	

	else if (currentMenuID == 43){
		drawNoRecords();
	}	
		
	else if (currentMenuID == 51)
		drawMoodOrActivity();
	
    else if (currentMenuID == 70)
		drawSettings();
		
    else if (currentMenuID == 71){
		drawChangeTime();
		manipulateTime = NEUTRAL;
	}		
		
    else if (currentMenuID == 72)
		drawInvertColourScheme();

    else if (currentMenuID == 73){
		drawResetRecords(0);
	}

    else if (currentMenuID == 74){
	    drawResetRecords(1);
    }		
		
	else if (currentMenuID == 80)
		drawUpload();
		
}	
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;

    game.numberDefenseMissiles=0;
    
    //JG
    game.nparticles=MAX_PARTICLES;
    game.numberDefenseMissiles=0;

    // JBC 5/19/16
    // added globally accesible defMissileSpeed so that we can 
    // change it dynamically
    game.defMissileSpeed = 10;

    initStruc(&game);
    //Structures sh;

    //Changed call for function prototype 5-17-16 -DT
    createEMissiles(&game, 0, 0);
    initRadar(&game);
    initUFO(&game);
    initHighScores(&game);
    //JR - Menu Object Shapes and Locations
    drawMenu(&game);
    drawSettings(&game);
    game.sounds.loadAudio();
    //start animation
    while (!done) {
        int state = gameState(&game);
        while (XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            done = check_keys(&e, &game);
        }
        if (state == 1) {
            render_menu(&game);
        } else if (state == 2) {        	
    		drawSettings(&game);
            render_settings(&game);
        } else if (state == 3) {
            render_newgame(&game);
        } else if (state == 0 || state == 5) {
            if (lvlState(&game) < 0) {
                movement(&game);
                render(&game);
            } 
            if (lvlState(&game) == 1) {
                levelEnd(&game);
            }
        } else {
            render_gameover(&game);
        }
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    return 0;
}