Пример #1
0
//-----------------------------------------------------------------------------
// Take all the players not in battles and shuffle them into new groups
void ShufflePlayers( void )
{
	int iArenaNum = 0;

	// Reset all Arenas
	int i;
	for ( i = 0; i < MAX_ARENAS; i++)
	{
		g_pArenaList[i]->Reset();
	}

	// Play the winners off against the other winners first
	iArenaNum = AddPlayers( GAME_WON, iArenaNum );
	// First, add the players who didn't play at all
	iArenaNum = AddPlayers( GAME_DIDNTPLAY, iArenaNum );
	// Then add the losers
	iArenaNum = AddPlayers( GAME_LOST, iArenaNum );

	// Then tell all full arenas to start 
	for (i = 0; i < MAX_ARENAS; i++)
	{
		if ( g_pArenaList[i]->IsFull() )
		{
			g_pArenaList[i]->StartBattle();
		}
		else
		{
			// If the arena has players in it, move them to the first full arena
			if ( g_pArenaList[i]->m_iPlayers != 0 )
			{
				for ( int j = 1; j <= gpGlobals->maxClients; j++ )
				{
					CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex( j );

					if (pPlayer && (pPlayer->m_pCurrentArena == g_pArenaList[i]) && (pPlayer->m_bHasDisconnected != TRUE) )
					{
						// Add to the first arena
						g_pArenaList[0]->AddClient( pPlayer, TRUE );

						pPlayer->m_iLastGameResult = GAME_DIDNTPLAY;
					}
				}
			}
		}
	}

}
Пример #2
0
bool Player_data::Load_Story()
{
    num_players=0;
    char temname[21]="";
    char tru[21]="";
    Ex_player new_;
    FILE *fp=fopen("ex_ending.txt","r");
    if(fp==0) return false;
    while(fscanf(fp,"%s %s",temname,tru)==2)
    {
        new_.Create(temname,tru);
        if(AddPlayers(new_)==false) return false;
    }
    fclose(fp);
    return true;
}
Пример #3
0
int CGame::SetupGame(char *argv[]) {

	int bpp = 32; //bits per pixel (truecolor)
	
	//buffers for filename manipulation
	char fullpath[255];
	char filename[10]; 

	int ret; //catches return values for processing
	int i;  //universal loop counter

	//initialise allegro stuff
	allegro_init(); 
	install_keyboard(); 
	install_mouse(); 
	install_timer();

	set_color_depth(bpp);
	
	/* Lets play the color depth game!  tries 32, 24, then 16 bit color modes */
	// set resolution to play intro movie
	ret = set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
	/* did the video mode set properly? */
	if (ret != 0) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Error setting %d bit graphics mode\n%s\nLets try another color depth!", bpp, allegro_error);
		
		bpp = 24;
		set_color_depth(bpp);
		
		// set resolution
		ret = set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
		/* did the video mode set properly? */
		if (ret != 0) {
			set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
			allegro_message("Error setting %d bit graphics mode\n%s\nLets try another color depth!", bpp, allegro_error);

			bpp = 16;
			set_color_depth(bpp);

			// set resolution
			ret = set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
			/* did the video mode set properly? */
			if (ret != 0) {
				set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
				allegro_message("Error setting %d bit graphics mode\n%s\nIm all out of options. Exiting", bpp, allegro_error);
				return 1;
			}
		}
	}
	
	// Load data from data.dat into memory
	textout_centre(screen,font,"NOW LOADING",SCREEN_W/2,SCREEN_H/2,makecol(255,255,255));

	sprintf(filename,"data.dat");
	replace_filename(fullpath, argv[0], filename, sizeof(fullpath));
    data = load_datafile(fullpath);
	if (!data) { 
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Cant load file %s for some reason.\nIt should be in the same directory as the .exe\n"
		"If you have deleted the debug directory to mark this then\ncopy all files from the \"required files\""
		"directory into the directory with the .exe\n\nThanks. Scarbble will now crash horribly", filename);
		return 1;
	}

	//make smaller copy of all tiles
	for (i=0;i<27;i++) {
		smalltiles[i] = create_bitmap(29,29);
		rotate_scaled_sprite(smalltiles[i], (WINDOWS_BITMAP *)data[i].dat, 0,0, 0, ftofix(0.8));
	}
		
	PlayIntro();

	AddPlayers();

	//stuff that cant be done in the players constructor
	InitialisePlayers();
	
	//set video mode to play game
	ret = set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0);
	/* did the video mode set properly? */
	if (ret != 0) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Error setting %d bit graphics mode\n%s\n", bpp, allegro_error);
		return 1;
	}
	
	//initialise the 'background' screen buffer
	background = create_bitmap(SCREEN_W, SCREEN_H);
	clear(background); //clear to black
	boardcolor = makecol(206,206,90);

	show_mouse(screen);
		
	return 0;
}