Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// Name : DrawObjects () (Private)
// Desc : Draws the game objects
//-----------------------------------------------------------------------------
void CGameApp::DrawObjects()
{
	m_pBBuffer->reset();

	HDC hdc = m_pBBuffer->getDC();

	m_imgBackground.Paint(hdc, 0, 0);

	if(GameOver == false && level.Winner == false && LevelChange == false)
	{
		DrawFunctor drawFn;
		std::for_each(m_vGameObjects.begin(), m_vGameObjects.end(), drawFn);
		std::for_each(m_vGameObjectsGift.begin(), m_vGameObjectsGift.end(), drawFn);
		std::for_each(m_vGameObjectsAnimate.begin(), m_vGameObjectsAnimate.end(), drawFn);
	}
	else
	{
		if(LevelChange == true)
			DrawGame(hdc,"level");
		if(level.Winner == true)
		{
			DrawGame(hdc,"winner");
			if(countGameOver == 0)
			{
				SaveScore();
				ScoreTable();
			}
			ShowScoreTable(hdc);
			countGameOver++;
		}
		if(GameOver == true)
		{
			DrawGame(hdc,"gameover");
			if(countGameOver == 0)
			{
				SaveScore();
				ScoreTable();
			}
			ShowScoreTable(hdc);
			countGameOver++;
		}
	}

	DrawScore(hdc);
	DrawLife(hdc);

	m_pBBuffer->present();
}
void Init(){ 

  int activeStructures[8] = {7,6,2,3,4,5,1,0};
  
  srand(time(0));
  MYS_Menu_SetMenu(&MainMenu,35,3,10);
  MYS_Menu_SetMenu(&SettingsMenu,35,3,10);
  
  MYS_Menu_AddToMenu(&MainMenu,"PLAY\0");
  MYS_Menu_AddToMenu(&MainMenu,"BEST SCORE\0");
  MYS_Menu_AddToMenu(&MainMenu,"SETTINGS\0"); 
  MYS_Menu_AddToMenu(&MainMenu,"EXIT\0");
  
  
  MYS_Menu_AddToMenu(&SettingsMenu,"MATRIX SIZE\0");
  MYS_Menu_AddToMenu(&SettingsMenu,"NUMBER RANGE\0");
  MYS_Menu_AddToMenu(&SettingsMenu,"STRUCTRES\0"); 
  MYS_Menu_AddToMenu(&SettingsMenu,"PLAYER NAME\0");
  MYS_Menu_AddToMenu(&SettingsMenu,"BACK\0");
  
  MYS_Score_SetScore(&Board.settings.player,0,"NO NAME\0",HEART);
  MYS_Score_SetScore(&HighScore,0,"NO NAME\0",HEART);
  
  ReadScore(); 
  SaveScore();
  
  Board.settings.matrixSize = 5;
  Board.settings.range[0] = 2;
  Board.settings.range[1] = 10;
  
  MYS_Settings_CreateStructures(&Board.settings,activeStructures,8);
  }
Exemplo n.º 3
0
void Score::LoadScore()
{
	if ((error = fopen_s(&fp, name, "rb")) != 0)
	{
		SaveScore();
		printfDx("\n新しく[score_data.dat]を作成しました。\n[Y] キー:おk\n");
	}
	else
	{
		fread(&hi_score, sizeof(hi_score), 1, fp);
		fclose(fp);
	}
}
Exemplo n.º 4
0
void Trivia::LoadScore()
{
	std::vector<std::string> scores = Util::readLinesFromFile("scoreboard.txt");

	for (size_t i = 0; i < scores.size(); ++i)
	{
		std::vector<std::string> words;
		getWordsSeperatedBy(scores[i], TRIVIA_WORDS_SEPERATOR, words);

		if (words.size() == 2)
			m_uoScore[words[0]] = (uint32)atoi(words[1].c_str());
		else
			printf("Trivia::LoadScore - Issue reading score at line %d, found %d words\n", i, words.size());
	}

	SaveScore();
}
void StartGame() {
  SCORE score;
  ResetScore(&score);
  while (1) {
    p_r_s player_choice;
    p_r_s machine_choice;
    // What the player picks?
    char c = GetUserInput();
    // Do we choose a control key rather than p r s?
    int controlKey = 0;
    switch (c) {
    case 'p':
      player_choice = paper;
      break;
    case 'r':
      player_choice = rock;
      break;
    case 's':
      player_choice = scissors;
      break;
    case 'g':
      PrintScore(&score);
      controlKey = 1;
      break;
    case 'h':
      PrintHelp();
      controlKey = 1;
      break;
    case 'e':
      PrintScore(&score);
      exit(0);
    default:
      PrintHelp();
      controlKey = 1;
      break;
    }
    if (controlKey)
      continue;
    // What the machine picks?
    machine_choice = MachineSelect();
    outcome re = Compare(player_choice, machine_choice); 
    PrintRoundResult(player_choice, machine_choice, re);
    SaveScore(re, &score);
  }
  return;
}
int searchForStructures(){
     char tempBoard[ (BOARD_MAX_SIZE+4) * (BOARD_MAX_SIZE+4)]; 
     int i,j,finded,matrixSize,rtr;
     finded = 1;j = 0;rtr = 0;
     matrixSize = Board.settings.matrixSize;
     for(i = 0;i < (matrixSize+4) * (matrixSize+4);i++){
             if(i % (matrixSize+4) < 2 || i %(matrixSize+4) >= matrixSize+2 || 
                i / (matrixSize+4) < 2 || i/(matrixSize+4) >= matrixSize+2)tempBoard[i] = 0;
             else {
                  tempBoard[i] = Board.Board[j];
                  j++;
                  }
     }
	 while(finded){
     finded = 0;
	 i = 0;
     while(i < Board.settings.numberOfStructures && !finded){ 
             j = 0;
             while(j < (matrixSize+2)*(matrixSize+2) && !finded ){
                     if(controlStructure(tempBoard,j,i)){//verilen index ile structure ı karşılaştırıyor
                                  finded = 1;
								  rtr = 1;
								  Board.settings.player.score += Board.settings.structures[i].point;
								  clearStructure(tempBoard,j,i);
                                  if(Board.settings.player.score > HighScore.score){
								  MYS_Score_SetScore(&HighScore,Board.settings.player.score,Board.settings.player.name,3);
								  SaveScore();
								  }														   
					 }
                     if( j % (matrixSize+4) == matrixSize+2)j += 2;
                     else j++;
                     }
             i++;
             } 
    }
                     //sleep(30000);
             return rtr;
     }
Exemplo n.º 7
0
void Trivia::ProcessAnswer(const std::string name, const std::string answer)
{
	if (!isQuestionInProgress())
		return;

	if (isAnswerCorrect(m_uiCurQuestion, answer))
	{
		m_vDelayedMsgs.clear();

		uint8 points = m_vQuestions[m_uiCurQuestion].points;

		m_uoScore[name] += points;

		std::string answerString;

		for (size_t i = 0; i < m_vQuestions[m_uiCurQuestion].answers.size(); ++i)
			answerString.append(m_vQuestions[m_uiCurQuestion].answers[i]);
		
		queueMessage("He has done it! User " + name + " gains " + std::to_string(points) + " points for a total of " + std::to_string(m_uoScore[name]) + "!", 1000);
		queueMessage("The answer(s): " + answerString, randomChoice(3000, 4000));
		SaveScore();
		queueNextQuestion(false);
	}
}
Exemplo n.º 8
0
/**
 * \brief The main game loop. This just cycles endlessly, it uses the game's 'state' to determine which screen to show and what to do.
 */
int main(){
	//looping back and forth forever (cards against humanity reference)
	while(1)
	{
		//some basic prep work performed once before our custom intro
		if(game_state == INTRO)
		{
			initialSetup();
			initIntro();
		}
		//perform custom intro
		while(game_state == INTRO)
		{
			//wait until the next frame
			WaitVsync(1);
			drawIntro();
			processIntro();
		}
		//prep the main menu
		if(game_state == MAIN_MENU)
		{
			FadeOut(0,true);
			ClearVram();
			SetTileTable(title_tiles);
			SetFontTilesIndex(TITLE_TILES_SIZE);
			drawMainMenu();
			FadeIn(0,false);
		}
		//draw menu and handle input
		while(game_state == MAIN_MENU)
		{
			WaitVsync(1);
			drawMenuCursor();
			processMainMenu();
		}
		if(game_state== GAME)
		{
			//run our setup for the main game
			ClearVram();
			FadeOut(0,true);
			gameSetup();
			FadeIn(0,false);
		}
		//when we're in the gameplay portion, draw and accept input for the game
		while(game_state == GAME)
		{
			WaitVsync(1);
			processScrollSpeed(); //scrolls screen as appropriate
			updateCity(); //offsets city for parallax
			processControls(); //accepts and processes controller input
			processPlayerMotion(); //update player position
			processSprites(); //updates and moves player image to player position
		}
		if(game_state == HIGH_SCORES)
		{
			FadeOut(0,true);
			SetTileTable(title_tiles);
			SetFontTilesIndex(TITLE_TILES_SIZE);
			drawLocalHighScoreMenu(); //draw up the high score screen
			FadeIn(0,false);
			deathclock=120; //reset death timer to 2 seconds
			if(score > topscores[9])
			{
			    LoadScore(0, 9); //load top 10 saved high scores
			    SaveScore(score); //save our current score if it's high enough
			    drawLocalHighScoreMenu(); //draw up the high score screen
			}
		}
		//draw and accepts input for the local high score screen
		while(game_state == HIGH_SCORES)
		{
			WaitVsync(1);
			processHighScoreMenu();
		}
    }
}
int main(int argc, char *argv[]){ 
  char esc,tmp,strInputs[8] = {'I','T','L','F','C','U','E','O'};
  int i,j,activeStructures[8];
  Init();
  while(1){
           char c,c2;
           if(MainMenu.buttons[0].clicked){//PLAY button
                                           gameInit();
                                           gameRun();
                                           MainMenu.buttons[0].clicked = 0;
                                           }
           else if(MainMenu.buttons[1].clicked){//BEST SCORE button
                printf("Name : %s   Best Score : %d",HighScore.name,HighScore.score);
                getch();
                MainMenu.buttons[1].clicked = 0;
                }
           else if(MainMenu.buttons[2].clicked){//SETTINGS button
                if(SettingsMenu.buttons[0].clicked){//MATRIXSIZE button
                     printf("Current Matrix Size : %d",Board.settings.matrixSize);
                     printf("\nPress Enter To Change...");
                     c2 = getch();
                     if(c2 == 13) {
                           printf("\nNew Size : ");
                           scanf("%d",&Board.settings.matrixSize);
						   if(Board.settings.matrixSize > BOARD_MAX_SIZE)Board.settings.matrixSize = BOARD_MAX_SIZE;
						   else if(Board.settings.matrixSize < 5)Board.settings.matrixSize = 5;
                           printf("Current Matrix Size : %d",Board.settings.matrixSize);
                           getch();
                     }
                     SettingsMenu.buttons[0].clicked = 0;
                     }
                else if(SettingsMenu.buttons[1].clicked){//RANGE button
                     printf("Number Range : %d , %d",Board.settings.range[0],Board.settings.range[1]);
                     printf("\n(Difference must be greater then 2 <2,10>)\nPress Enter To Change...");
                     c2 = getch();
                     if(c2 == 13) {
                           printf("\nRange Begin : ");
                           scanf("%d",&Board.settings.range[0]);
						   if(Board.settings.range[0] < 2)Board.settings.range[0] = 2;
                           printf("Range End : ");
                           scanf("%d",&Board.settings.range[1]);
						   if(Board.settings.range[1] > 10)Board.settings.range[1] = 10;
						   if(Board.settings.range[0] > Board.settings.range[1] - 2){
						   Board.settings.range[0] = 2;
						   Board.settings.range[1] = 10;
						   }
                           printf("\nNew Number Range : %d , %d",Board.settings.range[0],Board.settings.range[1]);
                           getch();
                      }
                     SettingsMenu.buttons[1].clicked = 0;
                     }
                else if(SettingsMenu.buttons[2].clicked){//STRUCTURE button

				     printf("Active Structures : ");
				     for(i = 0;i < Board.settings.numberOfStructures;i++)printf(" %c ",Board.settings.structures[i].name);
                     printf("\nAvaliable Structures : I T L C E F O U");
                     printf("\nPress Enter To Change...");
                     c2 = getch();
                     if(c2 == 13) {
					       printf("\n\nThe characters you used will be saved up till you use different ones\n\n");//ingilizceye çevir
					       i = 0;
						   esc = 0;
						   while(i < 8 && !esc){
								j = 0;
								printf("Enter Structure : ");
								scanf(" %c",&tmp);
								while(j < 8 && strInputs[j] != tmp && strInputs[j] != (tmp-'a'+'A') )j++;
								if(j < 8)activeStructures[i] = j;
								else esc = 1;
								i++;
						   }
						   if(i > 1){
								if(!esc)MYS_Settings_CreateStructures(&Board.settings,activeStructures,i);
								else MYS_Settings_CreateStructures(&Board.settings,activeStructures,i-1);
						   }
						   printf("Active Structures : ");
						   for(i = 0;i < Board.settings.numberOfStructures;i++)printf(" %c ",Board.settings.structures[i].name);
						   getch();
					 }
                     SettingsMenu.buttons[2].clicked = 0;
                     }
                else if(SettingsMenu.buttons[3].clicked){//PLAYER NAME button
					 char name[32];
					 printf("Current Name : %s",Board.settings.player.name);
                     printf("\n(Name Length must be greater then 2)\nPress Enter To Change...");
                     c2 = getch();
                     if(c2 == 13) {
                           printf("\nNew Name : ");
                           gets(name);
						   if(strlen(name) > 2)
                           strcpy(Board.settings.player.name,name);
						   printf("Current Name : %s",Board.settings.player.name);
						   SaveScore();
                           getch();
                     }
                     SettingsMenu.buttons[3].clicked = 0;
				
				}
				else if(SettingsMenu.buttons[4].clicked){//BACK button
                     SettingsMenu.buttons[4].clicked = 0;
                     MainMenu.buttons[2].clicked = 0;
                     MainMenu.focusedButtonIndex = 0;
                     }
                else{
                     drawMenu(&SettingsMenu);
                     c = getch();
                     if(c == 27){//BACK button
                          SettingsMenu.buttons[4].clicked = 0;
                          MainMenu.buttons[2].clicked = 0;
                          MainMenu.focusedButtonIndex = 0;
                          }
                     else menuInput(&SettingsMenu,c);
                     }
                }
           else if(MainMenu.buttons[3].clicked){//EXIT button
                printf("CODED BY EMRE KUL");
                getch();
                return;
                }
           else {//w s enter key
                drawMenu(&MainMenu);
                c = getch();
                menuInput(&MainMenu,c);
                } 
           system("cls");    
   }
  return 0;
}
Exemplo n.º 10
0
Score::~Score()
{
	SaveScore();
}