Ejemplo n.º 1
0
Trivia::Trivia(TwitchIRC* pOwner) :
	m_pOwner(pOwner),
	m_iQuestionExpireTimer(0),
	m_iNextQuestionTimer(0),
	m_uiCurQuestion(0),
	m_ctLastUpdate(clock())
{
	// Need a TwitchIRC for this class to work
	ASSERT(m_pOwner);

	LoadScore();
	LoadTrivia();
}
Ejemplo n.º 2
0
Score::Score()
	: graphic(new Graphic)
	, name("score_data.dat")
	, x_pos(200)
	, y_pos(10)
	, x_hi(600)
	, y_hi(y_pos)
	, hi_score(0)
	, val_score(0)
	, c_secscore(0)
	, secBonus(0)
	, f_exist(true)
{
	LoadScore();	// ハイスコアデータをロードするよ
	score = 0;
}
Ejemplo n.º 3
0
/**
 * \brief Performs some basic initialization functions.
 *
 * Sets up our graphics, initializes a few variables for convenience, loads saved scores and gets the music going.
 */
static void initialSetup()
{
	SetSpritesTileTable(ghost_sprites); //sets the tiles to be used for our various sprites
	SetFontTilesIndex(TITLE_TILES_SIZE); //tiles for the font were included immediately after the include for background tiles
	                               //therefore this says how many tiles in memory to move forward from the first one
	                               //in order to find the beginning of the font tiles
	SetTileTable(title_tiles); //sets the tiles to be used for the normal background tiles in the game
	                     //fonts use this and the index above to set font tiles
	InitMusicPlayer(patches); //initialize the sound engine
	SetMasterVolume(0xff); //set volume to max
	StartSong(midisong); //start playing the main theme
	ClearVram(); //fill entire screen with first tile in the tileset (blank the screen)

	//set up some convenience variables for changing player image and drawing the score
	player_sprites[0]=ghost0;
	player_sprites[1]=ghost1;
	player_sprites[2]=ghost2;
	player_sprites[3]=ghost3;
	player_sprites[4]=ghost4;
	player_sprites[5]=ghost5;
	player_sprites[6]=ghost6;
	player_sprites[7]=ghost7;
	player_sprites[8]=ghost8;
	numbers[0]=num0;
	numbers[1]=num1;
	numbers[2]=num2;
	numbers[3]=num3;
	numbers[4]=num4;
	numbers[5]=num5;
	numbers[6]=num6;
	numbers[7]=num7;
	numbers[8]=num8;
	numbers[9]=num9;

	//checks if our desired eeprom block is setup correctly,
	//if not, it wipes it so we don't have to deal with garbage data in the high score list
	if(checkEeprom()==1)
	{
		wipeEeprom();
	}
	//load our top 10 saved scores from eeprom
	LoadScore(0, 9);
}
Ejemplo n.º 4
0
bool Stats::SaveScore(std::wstring playername)
{
	std::wfstream _file;
	_file.open(m_filename);
	if(!_file.is_open())		//If file failed to open, return false
		return false;

	if (_file.peek() == std::fstream::traits_type::eof()) //If file is empty to begin with, just write down our new score
	{
		_file << "1|" << playername.c_str() << "|" << m_score << std::endl;
		return true;
	}
	
	_file.close();
	LoadScore();
	_file.open(m_filename);

	bool _placed = false;
	std::pair<std::wstring, int> _outData[10] = { { L"", 0 } };
	for (int i = 0, j = 0; i < 10; i++, j++)
	{
		if (m_score > m_highScores[i].second && !_placed)		//current score is bigger than score at pos i
		{
			_outData[i].first = playername;
			_outData[i].second = m_score;
			i++;
			_placed = true;
		}

		if (i != 10) {									//Add in existing score
			_outData[i] = m_highScores[j];
		}
	}
	
	//Clear and write file
	_file.clear();
	for (int i = 0; i < 10; i++) {
		_file << i+1 << '|' << _outData[i].first << '|' << _outData[i].second << std::endl;
	}
	_file.close();
}
Ejemplo n.º 5
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();
		}
    }
}