示例#1
0
文件: Top10.cpp 项目: Zyoruk/galaxy
void Top10::AddScore(string name, unsigned int score, unsigned int kills) {
	
	//Create a temporal register
	Score new_register(name, score, kills);
			
	//Insert the register
	scores.push_back(new_register);

	//Debug :: Print the list
	//PrintScores();	//*****************************//
		
	//Sort the list
	scores.sort();
	
	//Debug :: Print the list
	//PrintScores();	//*****************************//
	
	//Removes the las element
	scores.pop_back();
	
	//Debug :: Print the list
	//PrintScores();	//*****************************//
	
	//Save the score to a file
	SaveScores();
	
}
示例#2
0
HighScores::~HighScores()
{
	ROCKET_ASSERT(instance == this);

	SaveScores();

	instance = NULL;
}
示例#3
0
//================================================================================================//
Engine::~Engine(void)
{
	gLog.OutPut("\n[Engine Shutdown]\n");
	ilShutDown();
	FSOUND_Close();  
	SDL_Quit();
	SaveScores();
	gLog.OutPut("Complete...\n\n");
}
示例#4
0
int ZapHighScores(void)
{
	MFont *chicago;
	Maclike_Dialog *dialog;
	int X, Y;
	SDL_Surface *splash;
	Mac_Button *clear;
	Mac_Button *cancel;

	/* Set up all the components of the dialog box */
#ifdef CENTER_DIALOG
	X=(SCREEN_WIDTH-CLR_DIALOG_WIDTH)/2;
	Y=(SCREEN_HEIGHT-CLR_DIALOG_HEIGHT)/2;
#else	/* The way it is on the original Maelstrom */
	X=179;
	Y=89;
#endif
	if ( (chicago = fontserv->NewFont("Chicago", 12)) == NULL ) {
		error("Can't use Chicago font!\n");
		return(0);
	}
	if ( (splash = Load_Title(screen, 102)) == NULL ) {
		error("Can't load score zapping splash!\n");
		delete chicago;
		return(0);
	}
	dialog = new Maclike_Dialog(X, Y, CLR_DIALOG_WIDTH, CLR_DIALOG_HEIGHT,
								screen);
	dialog->Add_Image(splash, 4, 4);
	do_clear = 0;
	clear = new Mac_Button(99, 74, BUTTON_WIDTH, BUTTON_HEIGHT,
				"Clear", chicago, fontserv, Clear_callback);
	dialog->Add_Dialog(clear);
	cancel = new Mac_DefaultButton(99+BUTTON_WIDTH+14, 74, 
				BUTTON_WIDTH, BUTTON_HEIGHT,
				"Cancel", chicago, fontserv, Cancel_callback);
	dialog->Add_Dialog(cancel);

	/* Run the dialog box */
	dialog->Run();

	/* Clean up and return */
	screen->FreeImage(splash);
	delete chicago;
	delete dialog;
	if ( do_clear ) {
		memset(hScores, 0, sizeof(hScores));
		SaveScores();
		gLastHigh = -1;
	}
	return(do_clear);
}
示例#5
0
void AddScore(UINT32 score) {
    INT8 i, j;
    for (i = 0; i < MAX_SCORES; ++i) {
        if (score > game_data.scores[i]) {
            for (j = MAX_SCORES - 1; j > i; --j) {
                game_data.scores[j] = game_data.scores[j - 1];
            }
            game_data.scores[i] = score;
            break;
        }
    }
    SaveScores();
}
示例#6
0
文件: fuzed.cpp 项目: dave18/Fuzed
int main( int argc, char* args[] )
{

    int err,z;

    for (z=0;z<100;z++)
    {
        hiname[z]=(char*)malloc(5);
        //hiscores[z]=10000-z*100;
        hiscores[z]=0;
        hinew[z]=0;
        if (z&1) strcpy(hiname[z],"ED!"); else  strcpy(hiname[z],"FUZ");
    }


    #ifdef _WIN32
    _setmode( _fileno( stdin ), _O_BINARY );
    _setmode( _fileno( stdout ), _O_BINARY );
    #endif

    // Initialize all SDL subsystems
    err=SDL_Init( SDL_INIT_JOYSTICK | SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO );

    if (err ==-1)
    {
        printf(  "SDL Init error: %d\n",  err  );
        return 1;
    }
    screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF);
    SDL_ShowCursor(false);

    if (Mix_OpenAudio(44100, AUDIO_S16, MIX_DEFAULT_CHANNELS, 1024))
    {
        printf ("SDL Could not open sound hardware\n");
        soundpresent=0;
    }

    srand((int)SDL_GetTicks());

	// Do PC specific stuff
    #ifdef _WIN32
	// Set the window caption
	SDL_WM_SetCaption( "FuZeD", NULL );
    #endif // PLATFORM_PC

    SDL_Surface* intro_screen_scroll;
    SDL_Surface* intro_header;
    SDL_Surface* intro_footer;
    SDL_Surface* intro_icons;
    SDL_Surface* mouse_pointer;


    loadgfx(&intro_screen_scroll,(char*)"graphics/page_background_1280_scroll_wrap.png");
    loadgfx(&intro_header,(char*)"graphics/page_header.png");
    loadgfx(&intro_footer,(char*)"graphics/page_footer.png");

    loadgfx(&intro_icons,(char*)"graphics/intro_icons.png");
    loadgfx(&mouse_pointer,(char*)"graphics/mouse_pointer.png");

    loadgfx(&font,(char*)"graphics/16x16_font.png");
    loadgfx(&smallfont,(char*)"graphics/8x8_font.png");

    loadgfx(&spritemasks,(char*)"graphics/collmask.png");
    loadgfx(&coin_collide,(char*)"graphics/coin_collide.png");

    music = NULL;

    if (soundpresent)
    {

        mine_arm_snd=Mix_LoadWAV("audio/blips4.wav");
        explosion_snd=Mix_LoadWAV("audio/explosion_x.wav");
        collect_snd=Mix_LoadWAV("audio/sound005.wav");
        jump_snd=Mix_LoadWAV("audio/sound008.wav");
        bomb_land_snd=Mix_LoadWAV("audio/hammer.wav");
    }

    playercontrols[0].left=SDLK_LEFT;
    playercontrols[0].right=SDLK_RIGHT;
    playercontrols[0].cycle=SDLK_PAGEUP;
    playercontrols[0].jump=SDLK_PAGEDOWN;
    playercontrols[0].fire=SDLK_END;

    playercontrols[1].left=SDLK_z;
    playercontrols[1].right=SDLK_x;
    playercontrols[1].cycle=SDLK_c;
    playercontrols[1].jump=SDLK_t;
    playercontrols[1].fire=SDLK_f;

    playercontrols[0].joy=10; //keyboard
    playercontrols[1].joy=10;


InitCollisions(15);
level.Init();
wheelie.init();
grog.init();
slinky.init();
bomb.init();
explosion.init();
smoke.init();
mine.init();
dynamite.init();
player.init();
gem.init();
coin.init();
pickup.init();
pickedup16.init();
pickedup32.init();
hiscore.init();
LoadScores();
LoadSettings();
quitgame=0;
//level=new Tlevel;
while (quitgame==0)
{
    int keydata=0;
    int introscroll=0;
    int s1clip=640;
    long ticks=SDL_GetTicks();

    int exit_intro=0;
    int intro_option=0;
    startlevel=0;

    if (soundpresent)
    {
        if (music) Mix_FreeMusic(music);
        music = Mix_LoadMUS("audio/FuZED.title.Main.xm");
        if (!music) printf("SDL could not load music: %s\n" , SDL_GetError());
        if (music) Mix_PlayMusic(music, -1);
    }
    while (exit_intro<2)
    {
        introscroll+=4;
        if (introscroll>=1280) introscroll=0;
        s1clip=640-(introscroll-640);
        if (s1clip>640) s1clip=640;

        drawSprite(intro_screen_scroll, screen, introscroll, 0, 0, 96, s1clip, 352);
        if (s1clip<640) drawSprite(intro_screen_scroll, screen, 0, 0, s1clip, 96, 640-s1clip, 352);

        //drawSprite(intro_screen_scroll, screen, 0, 0, introscroll, 96, 1280, 352);
        //drawSprite(intro_screen_scroll, screen, 0, 0, 1280+introscroll, 96, 1280, 352);

        drawSprite(intro_header, screen, 0, 0, 0, 0, 640, 96);
        drawSprite(intro_footer, screen, 0, 0, 0, 448, 640, 32);

        drawSprite(intro_icons, screen, 0, 0, 32, 160, 96, 96);
        drawSprite(intro_icons, screen, 96, 0, 192, 160, 96, 96);
        drawSprite(intro_icons, screen, 192, 0, 352, 160, 96, 96);
        drawSprite(intro_icons, screen, 288, 0, 512, 160, 96, 96);

        drawSprite(intro_icons, screen, 288+96, 0, 32, 300, 96, 96);
        drawSprite(intro_icons, screen, 288+192, 0, 192, 300, 96, 96);
        drawSprite(intro_icons, screen, 288+288+96, 0, 352, 300, 96, 96);
        drawSprite(intro_icons, screen, 288+288, 0, 512, 300, 96, 96);


        drawSprite(mouse_pointer, screen, 0, 0, mx,my, 19, 31);

        if (images_collide(mx, my, 8, 8, mouse_pointer, 0, 0, 24, 31, 0xFF00FF, 32, 160, 96, 96, intro_icons, 0, 0, 96, 96, 0xFF00FF))
        {
            Text((char*)"SINGLE PLAYER",216,462);
            if (keydata & MY_BUTT_B)
            {
                exit_intro=2;
                intro_option=0;
            }
        }
        if (images_collide(mx, my, 8, 8, mouse_pointer, 0, 0, 24, 31, 0xFF00FF, 192, 160, 96, 96, intro_icons, 0, 0, 96, 96, 0xFF00FF))
        {
            Text((char*)"TWO PLAYER TEAM",200,462);
               if (keydata & MY_BUTT_B)
            {
                exit_intro=2;
                intro_option=1;
            }
        }
        //if (images_collide(mx, my, 8, 8, mouse_pointer, 0, 0, 24, 31, 0xFF00FF, 32, 160, 96, 96, intro_icons, 0, 0, 96, 96, 0xFF00FF)) Text((char*)"SINGLE PLAYER",216,462);
        //if (images_collide(mx, my, 8, 8, mouse_pointer, 0, 0, 24, 31, 0xFF00FF, 32, 160, 96, 96, intro_icons, 0, 0, 96, 96, 0xFF00FF)) Text((char*)"SINGLE PLAYER",216,462);
        if (images_collide(mx, my, 8, 8, mouse_pointer, 0, 0, 24, 31, 0xFF00FF, 512, 300, 96, 96, intro_icons, 0, 0, 96, 96, 0xFF00FF))
        {
            Text((char*)"EXIT GAME",248,462);
               if (keydata & MY_BUTT_B)
            {
                exit_intro=2;
                intro_option=7;
            }
        }


        SDL_Flip(screen);


        keydata=get_key(0);

//        printf("MS %d Millisecs\n",SDL_GetTicks()-ticks);
//        ticks=SDL_GetTicks();
    }

    if (soundpresent) Mix_HaltMusic();

    if ((intro_option>=0) && (intro_option<=3))
    {
		level.Create(startlevel);							//Create level (level id)
		player.spawn(1,level.GetPx(0),level.GetPy(0),2,0,0,3,1);		//Create Player 1
		if (intro_option>0) player.spawn(2,level.GetPx(1),level.GetPy(1),2,0,0,3,0);		//Create Player 2
		if (soundpresent)
		{
		    if (music) Mix_FreeMusic(music);
			if (startlevel<5) music = Mix_LoadMUS("audio/FuZED.lev.Checkers.xm");
			if ((startlevel>=5) && (startlevel<10)) Mix_LoadMUS("audio/FuZED.lev.Ancient.xm");

		}
		level.AddEnemies();

		level.Fadein();
		keydata=0;
        if ((soundpresent) && (music)) Mix_PlayMusic(music, -1);	//Start music playing
		while ((player.CountList()>0) && (QDOWN==0))
		{
		    while ((((player.CountList()>0) && (level.door_appear<4)) || hiscore.CountList()>0) && (QDOWN==0))
		    {
                level.Play();

                SDL_Flip(screen);
                keydata=get_key(0);
/*                if (keydata & MY_BUTT_A)
                {
                    SDL_SaveBMP(screen,"screenshot.bmp");
                    printf("screenshot saved\n");
                }*/
		    }
		    if ((player.CountList()>0) && (QDOWN==0))
		    {
				ClearAllLists();
				level.ScrollToNext();
				level.AddEnemies();
                player.InitialPosition();

		    }
		}

		level.Fadeout();
		ClearAllLists();
		player.ClearList();

    }


    if (intro_option==7) quitgame=1;
}
    Mix_FreeMusic(music);
    SaveScores();
    SaveSettings();
    SDL_Quit();

    return 0;

}