Exemplo n.º 1
0
void mathGame::gameMenu(){
	char start;
	cout << "[S]tart Game [H]igh Scores [Q]uit Game" << endl;
	cin >> start; cin.ignore(100, '\n');
	start = toupper(start);
	
	
		
		switch (start)
		{
		case 'S':
			while (stop(problemGenerator()))
			{
				showScore();
			}
			gameMenu();
			break;
		case 'H':
			setHighScore();
			gameMenu();
			break;
		case 'Q':
			break;
		default:
			cout << "Oops something happended!?" << endl;
			break;
		}
	



}
Exemplo n.º 2
0
void GUI::start( )
{
	std::cout <<"Don't delete this line";

	score = play( );

	if ( score > -1 )
	{
		setTextColor( COLOR );
		gotoxy( 20, 9 ); std::cout << "                                                   ";
		gotoxy( 20, 10); std::cout << "_______________________GAME OVER___________________";
		gotoxy( 20, 11); std::cout << "                                                   ";
		gotoxy( 20, 12); std::cout << "                   YOUR SCORE : " << score << "          ";
		gotoxy( 20, 13); std::cout << "                                                   ";
		
		//luu lai diem cao
		setHighScore( score );	
	
		Sleep(1500);
		
		getch();
	}
}
Exemplo n.º 3
0
void render(Game *g)
{        
	g->mouseThrustOn=false;    
	glClear(GL_COLOR_BUFFER_BIT);
	if(intro < 1) {
		char screen;
		if (selected_screen == LEFT){
			screen = 'L';
		}
		else{
			screen = 'R';
		}
		if (hud->isShowWelcome() == true){
			hud->showIntro(screen,introTexture, bgTexture1, bgTexture2);
			if (hud->getAI() == true){
				hud->selectAI();
			}
			else{
				hud->selectHuman();
			}
			return;
		}
		else if (hud->isShowHelpMenu() == true){
			hud->showHelpMenu(helpMenuTexture);
			return;
		}
		return;
	}
	else{
		renderTexture(bgTexture, xres, yres);
	}

	if (is_gameover){
		renderTexture(gameOverTexture, xres, yres);
		high_score = setHighScore(ball.getPlayer1Score(), ball.getPlayer2Score());
		//cout << "Final Score : " << high_score << "\n";
		hud->showGameOver(high_score,ball.getPlayer1Score(), ball.getPlayer2Score());
		return;
	}

	hud->showScore(ball.getPlayer1Score(), ball.getPlayer2Score());
	hud->showHealth(hud->getPlayer1Health(), hud->getPlayer2Health());
	hud->showCourtYard();

	//DRAW BOMB:
	if (level == 1){

		GLuint which_bomb_texture = bombTexture;
		if ((bombBegin + 2) > time(NULL)){
			which_bomb_texture = explodeTexture;
		}
		else{
			which_bomb_texture = bombTexture;
		}

		portal0.render(portalTexture0);
		portal1.render(portalTexture1);


		hud->renderBomb(which_bomb_texture,bomb_posx,bomb_posy,bomb_width,bomb_height);
	}

	//Draw the paddle
	glColor3f(0.0, 0.5, 0.5);
	paddle1.render();
	glColor3f(0.7, 0.5, 0.0);
	paddle2.render();
	glEnd();
	//Draw the ball
	ball.render();

	//If option 2 is selected i.e. ninja_robot.ppm is the background
	//Level 2 selected
	//Draw some obstacles to showcase a difference between level 1 and level2
	if(level == 2) {
		obstacle->render();
	}
	hud->showTimer(getTimer());
	if (hud->isPaused()){
		hud->showPaused(pausedTexture);
	}
}
Exemplo n.º 4
0
//////////////////////////////////////////////////////////////////
// game
//
//
//
// Returns:
//    void
//
void game(void) {
    u8 moved;
    u8 *pvmem;
    u8 dir = 0;


    initGame();

    // Clear Screen
    clearScreen();

    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 61, 72);
    cpct_drawSprite(logo_small, pvmem, 15, 55);

    //drawFrame(2, 1, 49, 182);
    drawTable();
    drawText("NEXT", 62, 2, 0);
    printCells();
    highestCardGame = getHighestCard();
    drawText("HIGHEST", 59, 138, 0);
    pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 154);
    cpct_drawSprite(cards[highestCardGame], pvmem, CARD_W, CARD_H);

    moved = 0;
    // Loop forever
    while (1) {
        delay(24);

        rotatedCells = 0;

        if ((cpct_isKeyPressed(Joy0_Right)) || (cpct_isKeyPressed(keys.right))) {
            if (rotateCellsRight() > 0) {
                dir = RIGHT;
                addRandomCellTurn(RIGHT);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Left)) || (cpct_isKeyPressed(keys.left))) {
            if (rotateCellsLeft() > 0) {
                dir = LEFT;
                addRandomCellTurn(LEFT);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Down)) || (cpct_isKeyPressed(keys.down))) {
            if (rotateCellsDown() > 0) {
                dir = DOWN;
                addRandomCellTurn(DOWN);
                moved = 1;
            }
        } else if ((cpct_isKeyPressed(Joy0_Up)) || (cpct_isKeyPressed(keys.up))) {
            if (rotateCellsUp() > 0) {
                dir = UP;
                addRandomCellTurn(UP);
                moved = 1;
            }

        } else if ( cpct_isKeyPressed(keys.music)) {
            if (!playing) {
                activateMusic();
            } else {
                deActivateMusic();
            }
        } else if (cpct_isKeyPressed(keys.abort))
            break;

        if (moved) {
            //Empty the rotated cells buffer after ending the animation
            //cpct_waitVSYNC();

            if (changedCards.number > 0) {
                animate(dir);
                resetChangedCards();

                highestCardGame = getHighestCard();
                pvmem = cpct_getScreenPtr(CPCT_VMEM_START, 63, 154);
                cpct_drawSprite(cards[highestCardGame], pvmem, CARD_W, CARD_H);

                // Play sound Effect
                cpct_akp_SFXPlay(3, 14, 50 + (highestCardGame * 2), 1, 0, AY_CHANNEL_A);

            }

            moved = 0;
            if (anyMovesLeft() == 0) {
                cpct_akp_stop();
                cpct_akp_musicInit(song05);
                cpct_akp_musicPlay();
                drawScore();
                wait4UserKeypress();
                drawFrame(14, 60, 68, 130);
                drawText("NO MORE MOVES", 20, 70, 1);
                drawText("GAME OVER", 22, 90, 1);
                sprintf(aux_txt, "SCORE  %d", score);
                drawText(aux_txt, 22, 110, 1);
                delay(200);
                wait4UserKeypress();
                setHighScore(score);
                drawScoreBoard();
                cpct_akp_stop();
                cpct_akp_musicInit(song02);
                cpct_akp_musicPlay();
                break;
            }
        }

    }
}
Exemplo n.º 5
0
int gameScreen(int lv0, int sc0){
	int i, inp;
	
	if( lv0 >= MAX_LEVEL || lv0 < 0 ){
		fprintf(stderr, "レベル指定が不正です\n");
		exit(1);
	}
	initGame(lv0, sc0);
	gdscr_initscr();
	
	gdscr_refresh();
	drawString(6, 40, "Press space key to start", FORMAT_CENTER);
	while( 1 ){
		inp = getch();
		if( inp == ' ' )break;
		if( inp == 'q' )break;
	}
	
	timeout(0);
	setLevel(LEVEL);
	while( !gbump_check() && inp != 'q' ){
	
		/*sleep処理*/
		usleep(DELAY);
	
		/*入力受付処理*/
		inp = getch();
		if( inp == ' ' ) gjump_flagSet();
		
		/*レベルアップ処理*/
		if( checkLevelUp() ){
			LEVEL++;
			setLevel(LEVEL);
		}
		
		/*画面更新処理*/
		gfield_shiftl();
		gobstacle_put(&FIELD[FIELD_WIDTH - 1]);
		gjump_jumpPlayer();
		SCORE++;
		gdscr_refresh();
	}
	
	/*終了処理*/
	setHighScore(SCORE);
	SCORE_HIGH = getHighScore();
	timeout(-1);
	freeMatrix(PLAYER_MATRIX);
	PLAYER_MATRIX = PLAYER_MATRIX_LOSE;
	
	/*終了画面描画*/
	gdscr_draw();
	drawString(5, 5, "GAME OVER.", FORMAT_LEFT);
	printCommand(22, 76, FORMAT_RIGHT, COMMAND_LIST, COMMAND_NUM);
	refresh();
	
	/*コマンド取得*/
	inp = getCommand(COMMAND_LIST, COMMAND_NUM);
	
	/*開放*/
	freeMatrix(PLAYER_MATRIX_LOSE);
	gobstacle_memFree();
	gdscr_endwin();
	
	/*メッセージ返却*/
	switch( inp ){
		case 'r':
			return COMMAND_RETRY;
		case 'm':
			return COMMAND_MENU;
		case 'q':
			return COMMAND_QUIT;
		default:
			return 9999;
	}
}
Exemplo n.º 6
0
void GameData::setScore( int score )
{
	mScore = score;
	setHighScore(score);
}