void update(double dt)
{
    // get the delta time
    elapsedTime += dt;
    deltaTime = dt;
	switch (g_eGameState){
        case CLASSSELECT: classSelect();
            break;
		case GAME: gameplay();
			break;
        case PAUSE: pausemenu();
            break;
		case GAMEOVER: gameend();
			break;
		case SPLASH: splashwait();
	}
}
Exemple #2
0
int checkkey(int dir) {    //Basically I need this function to check if the direction specified is valid or not i.e if already down, down will invalid
	int key;
	if(kbhit()) {  // if something is entered
		key = getch();
		if(dir != key) {
			if(key == DOWN && dir != UP)
				dir = key;
			else if(key == UP && dir != DOWN)
				dir = key;
			else if(key == RIGHT && dir != LEFT)
				dir = key;
			else if(key == LEFT && dir != RIGHT)
				dir = key;
			else if(key == ESC || key == PAUSE) 
				pausemenu();
		}	

	}
	return dir;
}
/*
    This is the render loop
    At this point, you should know exactly what to draw onto the screen.
    Just draw it!
    To get an idea of the values for colours, look at console.h and the URL listed there
*/
void render()
{
    clearScreen();                      // clears the current screen and draw from scratch 
	switch (g_eGameState) {
	case SPLASH: splash();              // splash screen
		break;
	case TITLE: titlescreen();          // title screen
		break;
    case VICTORY: victory();            // victory screen
        break;
    case CREDITS: credits();            // credits & statistics screen
        break;
    case PAUSE: pausemenu();            // pause screen
        break;
    case CLASSSELECT: classSelect();    // class selection screen
        break;
	case GAME: renderGame();            // Game screen
		break;
	case GAMEOVER: gameend();           // Retry screen
		break;
	}
	renderToScreen();// dump the contents of the buffer to the screen, one frame worth of game
}