Exemple #1
0
void RetrieveResources( void )
{
	                            OpeningProgress( 0, 10 );
	InitSound( );				OpeningProgress( 1, 10 );

	InitBackdrop( );			OpeningProgress( 2, 10 );

	GetBlobGraphics( );			OpeningProgress( 3, 10 );
	
	InitNext( );				OpeningProgress( 4, 10 );
	
	InitScore( );				OpeningProgress( 5, 10 );

	InitGrayMonitors( );		OpeningProgress( 6, 10 );
	
	InitOpponent( );			OpeningProgress( 7, 10 );

	InitStage( );   // must run after backdrop window is open
	InitGameTickCount( );

	InitPlayers( ); // must run after backdrop window is open
	InitFont( ); 
	InitZapStyle( );// must run after fonts are inited
					            OpeningProgress( 8, 10 );
	
	InitBlitter( ); // must run after player windows are open
	InitPlayerWorlds( );  		OpeningProgress( 9, 10 );
	
	InitVictory( );	// must run after fonts are inited			
	InitTweak( );				OpeningProgress( 10, 10 );
}
Exemple #2
0
int main(int argc, char *argv[])
{
    enum { GAME_COMPUTER, GAME_NETWORK, GAME_UNKNOWN } game_type = GAME_UNKNOWN;
    char *remote_address;
    int i;
	
    if (argc < 2) {
	printf("Penguin Warrior\n");
	printf("Usage: pw [ mode ] [ option ... ]\n");
	printf("  Game modes (choose one):\n");
	printf("    --computer\n");
	printf("    --net <remote ip address>\n");
	printf("  Display options, for tweaking and experimenting:\n");
	printf("    --fullscreen\n");
	printf("    --hwsurface  (use an SDL hardware surface if possible)\n");
	printf("    --doublebuf  (use SDL double buffering if possible)\n");
	printf("  The display options default to a windowed, software buffer.\n");
	exit(EXIT_FAILURE);
    }

    /* Process command line arguments. There are plenty of libraries for command
       line processing, but our needs are simple in this case. */
    for (i = 0; i < argc; i++) {

	/* Networked or scripted opponent? */
	if (!strcmp(argv[i], "--computer")) {
	    game_type = GAME_COMPUTER;
	    continue;
	} else if (!strcmp(argv[i], "--net")) {
	    game_type = GAME_NETWORK;
	    if (++i >= argc) {
		printf("You must supply an IP address for --net.\n");
		exit(EXIT_FAILURE);
	    }
	    remote_address = argv[i];
	    continue;

	    /* Display-related options */
	} else if (!strcmp(argv[i], "--hwsurface")) {
	    hwsurface = 1;
	} else if (!strcmp(argv[i], "--doublebuf")) {
	    doublebuf = 1;
	} else if (!strcmp(argv[i], "--fullscreen")) {
	    fullscreen = 1;
	}
    }

    switch (game_type) {
    case GAME_COMPUTER:
	opponent_type = OPP_COMPUTER;
	printf("Playing against the computer.\n");
	break; 
			
    case GAME_NETWORK:
	printf("Sorry, network play is not implemented... yet!\n");
	exit(EXIT_FAILURE);
			
    default:
	printf("You must select a game type.\n");
	exit(EXIT_FAILURE);
    }
	
    /* Initialize our random number generator. */
    initrandom();

    /* Fire up SDL. */
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
	printf("Unable to initialize SDL: %s\n", SDL_GetError());
	exit(EXIT_FAILURE);
    }
    atexit(SDL_Quit);
	
    /* Set an appropriate 16-bit double buffered video mode. */
    if (SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16,
			 (hwsurface ? SDL_HWSURFACE : SDL_SWSURFACE) |
			 (doublebuf ? SDL_DOUBLEBUF : 0) |
			 (fullscreen ? SDL_FULLSCREEN : 0)) == NULL) {
	printf("Unable to set video mode: %s\n", SDL_GetError());
	exit(EXIT_FAILURE);
    }
	
    /* Save the screen pointer for later use. */
    screen = SDL_GetVideoSurface();
	
    /* Set the window caption to the name of the game. */
    SDL_WM_SetCaption("Penguin Warrior", "Penguin Warrior");
	
    /* Hide the mouse pointer. */
    SDL_ShowCursor(0);

    /* Start the OpenAL-based audio system. */
    InitAudio();

    /* Initialize music and give the music system a file. */
    InitMusic();
    if (LoadMusic("reflux.ogg") != 0) {
	/* If that failed, don't worry about it. */
	printf("Unable to load reflux.ogg.\n");
    }
		
    /* Load the game's data into globals. We can only do this after the
       video and audio subsystems are ready for action, since the loading
       routines interact with SDL and OpenAL. */
    LoadGameData();

    /* Initialize the background starfield. */
    InitBackground();
	
    /* Play! */
    InitPlayer();
    InitOpponent();
    PlayGame();

    /* Unhide the mouse pointer. */
    SDL_ShowCursor(1);
	
    /* Unload data. */
    UnloadGameData();

    /* Shut down audio. */
    CleanupMusic();
    CleanupAudio();

    return 0;
}