Пример #1
0
int main() {

	PA_Init();    // Initializes PA_Lib
//	PA_InitVBL(); // Initializes a standard VBL

	PA_VBLFunctionInit(AS_SoundVBL);
	AS_Init(AS_MODE_MP3 | AS_MODE_SURROUND | AS_MODE_16CH);
	AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_SURROUND);

	PA_LoadDefaultText(1, 0);

	StartScreen();
	CreateTasks();
	initMap(map);

	vTaskStartScheduler();		// Never returns
	while (1)
		;
	return 0;
}
Пример #2
0
int main(){
	// Initialisation de la PAlib de l'affichage et du son
	PA_Init();    // Initialisation de la PALib
	PA_InitVBL(); // Initialisation de l'affichage
	AS_Init(AS_MODE_16CH); //son	
	AS_SetDefaultSettings(AS_PCM_8BIT, 16384, 0); //son (type,rate)
	
	splash(); //Splashscreen
	
	// Initialisation du texte
	PA_LoadDefaultText(0, 0); //bas
	PA_LoadDefaultText(1, 0); //haut
	PA_SetTextTileCol(1, TEXT_BLACK); // texte en noir (haut)
	PA_SetTextTileCol(0, TEXT_BLACK); // texte en noir (bas)
	
	//Palettes des couleurs pour les sprites des boutons (une seule suffit) (numéro 1)
	PA_LoadSpritePal(0, 1, (void*)plus_Pal);
	
	PA_LoadBackground(1, 1, &titre); // background de l'écran du haut
	
	//Accueil
	AS_SoundDefaultPlay(pinball, pinball_size, 127, 64, true, 0); //musique de fond en boucle
	fonduentree(); //fondu d'entrée 
	if(PA_UserInfo.Language == 2) {
		PA_LoadBackground(0, 1, &jouer);
	}
	else {
		PA_LoadBackground(0, 1, &play);
	}
	PA_OutputText(1, 17, 8, "2.1"); //version
	PA_WaitFor(Pad.Newpress.Anykey || Stylus.Newpress);
	AS_SoundQuickPlay(clic);
	fondusortie();
	
	//Nouvelle partie : etiquette et reset
	debut:
	PA_ClearTextBg(0); //efface tout le texte
	PA_ResetSpriteSys(); //efface tout les sprites
	PA_OutputText(1,1,22,"                                  ");
		
	// Les variables
	u32 nmax = 0; //Nombre maximal
	u32 nmin = 0; //Nombre minimal
	u32 coup = 0; //Nombre de coups
	u32 nombre = 0; //Nombre (valeur de départ)
	u32 diff = 0;
	u32 temps = 0;
	
	//Sélection de la difficulté.
	fonduentree();
	PA_LoadBackground(0, 1, &niveau);
	while(1) {
		
		if(PA_UserInfo.Language == 2) {
			PA_OutputText(0,5,4,"Facile             (B)");
			PA_OutputText(0,5,5,"(entre 10 et 25)");
			PA_OutputText(0,5,11,"Normal             (Y)");
			PA_OutputText(0,5,12,"(entre 10 et 60)");
			PA_OutputText(0,5,18,"Difficile          (X)");
			PA_OutputText(0,5,19,"(entre 10 et 95)");
		}
		else {
			PA_OutputText(0,5,4,"Easy               (B)");
			PA_OutputText(0,5,5,"(between 10 and 25)");
			PA_OutputText(0,5,11,"Normal             (Y)");
			PA_OutputText(0,5,12,"(between 10 and 60)");
			PA_OutputText(0,5,18,"Hard               (X)");
			PA_OutputText(0,5,19,"(between 10 and 95)");
		}
		
		if((PA_StylusInZone(29, 21, 227, 57) && Stylus.Newpress) || Pad.Newpress.A) {
		nombre = 12;
		nmax = 25;
		nmin = 10;
		diff = 1;
		break;
		}
		
		if((PA_StylusInZone(29, 79, 227, 115) && Stylus.Newpress) || Pad.Newpress.A) {
		nombre = 35;
		nmax = 60;
		nmin = 10;
		diff = 2;
		break;
		}
		
		if((PA_StylusInZone(29, 135, 227, 170) && Stylus.Newpress) || Pad.Newpress.A) {
		nombre = 52;
		nmax = 95;
		nmin = 10;
		diff = 3;
		break;
		}
		
		PA_WaitForVBL();
	}
	
	u32 dsnum = PA_RandMinMax(nmin, nmax); //La valeur aléatoire entre 40 et 70
	
	PA_LoadBackground(0, 1, &jeu); //chargement du bg de jeu
	
	//Reset pour effacer l'écran de choix de la difficulté
	PA_ClearTextBg(0);
	
	//Bouton + - et +5 -5
	PA_CreateSprite(0, 0, (void*)plus_Sprite, OBJ_SIZE_32X32, 1, 1, 40, 33);
	PA_CreateSprite(0, 1, (void*)moins_Sprite, OBJ_SIZE_32X32, 1, 1, 40, 110);
	PA_CreateSprite(0, 2, (void*)okb_Sprite, OBJ_SIZE_32X32, 1, 1, 218, 157);
	PA_CreateSprite(0, 4, (void*)moins5_Sprite, OBJ_SIZE_32X32, 1, 1, 75, 110);
	PA_CreateSprite(0, 5, (void*)plus5_Sprite, OBJ_SIZE_32X32, 1, 1, 75, 33);	

	// Boucle principale
	PA_VBLCounterStart(0);
	while (1)
	{
	PA_OutputText(0,8,22,"%d", coup);
	//PA_OutputText(1,1,20,"La DS pense à : %d", dsnum);  // Débug
	//PA_OutputText(1,1,19,"Temps : %d", PA_VBLCounter[0]/60); // Débug
	if(PA_UserInfo.Language == 2) {
		if(diff == 1) {
			PA_OutputText(1,1,22,"Facile (entre %d et %d)",nmin, nmax);
		}
		if(diff == 2) {
			PA_OutputText(1,1,22,"Normal (entre %d et %d)",nmin, nmax);
		}
		if(diff == 3) {
			PA_OutputText(1,1,22,"Difficile (entre %d et %d)",nmin, nmax);
		}
	}
	else {
		if(diff == 1) {
			PA_OutputText(1,1,22,"Easy (between %d and %d)",nmin, nmax);
	}
	if(diff == 2) {
			PA_OutputText(1,1,22,"Normal (between %d and %d)",nmin, nmax);
	}
	if(diff == 3) {
			PA_OutputText(1,1,22,"Hard (between %d and %d)",nmin, nmax);
	}	
	}
	
	if(PA_UserInfo.Language == 2) {
		PA_OutputText(0,4,10,"Votre nombre:");
	}
	else {
		PA_OutputText(0,4,10,"Your number:");
	}
	PA_OutputText(0,4,12,"%d", nombre);
	if(PA_UserInfo.Language == 2) {
		PA_OutputText(0,1,22,"Coups:");
	}
	else {
		PA_OutputText(0,1,22,"Tries:");
	}
	
	if(Pad.Newpress.Up || (Stylus.Newpress && PA_SpriteTouched(0))) {
		nombre++;
		AS_SoundQuickPlay(clic);
	}
	if(Pad.Newpress.Down || (Stylus.Newpress && PA_SpriteTouched(1))) {
		nombre--;
		AS_SoundQuickPlay(clic);
	}	
	if(Pad.Newpress.Left || (Stylus.Newpress && PA_SpriteTouched(4))) {
		nombre = nombre - 5;
		AS_SoundQuickPlay(clic);
	}	
	if(Pad.Newpress.Right || (Stylus.Newpress && PA_SpriteTouched(5))) {
		nombre = nombre + 5;
		AS_SoundQuickPlay(clic);
	}
	if(nombre < nmin) {
		nombre = nmin;
	}		
	if(nombre > nmax) {
		nombre = nmax;
	}
	if((PA_SpriteTouched(2) && Stylus.Newpress) || Pad.Newpress.A) {
		coup++;
		AS_SoundQuickPlay(clic);
		if (dsnum > nombre)
		{
			PA_OutputText(0,25,11,"          ");
			PA_OutputText(0,25,11,"Plus !");
		}
		if (dsnum < nombre)
		{
			PA_OutputText(0,25,11,"          ");
			if(PA_UserInfo.Language == 2) {
				PA_OutputText(0,25,11,"Moins !");
			}
			else {
				PA_OutputText(0,25,11,"Minus !");
			}
		}
		if (dsnum == nombre)
		{
			temps = PA_VBLCounter[0]/60;
			PA_WaitFor(Stylus.Released || Pad.Released.A);
			PA_ResetSpriteSys();
			PA_LoadBackground(0, 1, &gagne);
			PA_ClearTextBg(0); //efface tout le texte
			AS_SoundQuickPlay(ok);
			//Smiley qui applaudit	
			PA_LoadSpritePal(0, 0, (void*)applaudissement_Pal); // la palette du smiley (num 0)
			PA_CreateSprite(0, 3,(void*)applaudissement_Sprite, OBJ_SIZE_32X32,1, 0, 180, 45);
			PA_StartSpriteAnimEx(0, 3, 0, 4, 12, ANIM_LOOP, 7);
			
			if(PA_UserInfo.Language == 2) {
				PA_OutputText(0,15,6,"Gagné !");
				PA_OutputText(0,6,8,"Vous avez trouvé %d", dsnum);
				PA_OutputText(0,6,9,"en %d secondes", temps);
				PA_OutputText(0,6,10,"et %d coups.", coup);
				PA_OutputText(0,6,16,"START ou touchez");
				PA_OutputText(0,6,17,"l'écran pour rejouer.");
			}
			else {
				PA_OutputText(0,15,6,"Win !");
				PA_OutputText(0,6,9,"You find %d", dsnum);
				PA_OutputText(0,6,10,"in %d seconds", temps);
				PA_OutputText(0,6,11,"and %d tests. ", coup);
				PA_OutputText(0,6,15,"START or touch");
				PA_OutputText(0,6,16,"the screen to replay.");
			}
			
			//Recommencer le jeu avec l'etiquette debut
			PA_WaitFor(Stylus.Newpress || Pad.Newpress.Start);
			AS_SoundQuickPlay(clic);
			goto debut;
		}
	}
	PA_WaitForVBL(); //Rafraichissement à ne pas bouger/enlever	
	}

return 0;
}
Пример #3
0
int main() {

    PA_Init();    // Initialisation de la PALib
    PA_InitVBL(); // Initialisation de l'affichage

    splash();

    // Initialisation du texte, de la palette et du son
    PA_LoadDefaultText(0, 0); //bas
    PA_LoadDefaultText(1, 0); //haut
    PA_SetTextTileCol(1, TEXT_BLACK); // texte en noir (haut)
    PA_SetTextTileCol(0, TEXT_BLACK); // texte en noir (bas)
    PA_LoadSpritePal(0, 1, (void*)feu_Pal); // palette du feu
    PA_LoadSpritePal(0, 2, (void*)mario_Pal); //palette pour mario
    PA_LoadSpritePal(0, 3, (void*)boite_Pal); //palette pour la boite
    PA_LoadSpritePal(0, 4, (void*)piece_Pal); //palette pour la piece

    AS_Init(AS_MODE_16CH); //son
    AS_SetDefaultSettings(AS_PCM_8BIT, 8000, 0); //son (type,rate)
    AS_SoundDefaultPlay(fond_smgboss1, fond_smgboss1_size, 50, 64, true, 0); //musique de fond en boucle

    //Accueil
accueil:
    fonduentree(); //fondu d'entrée
    PA_LoadBackground(0, 1, &jeu);
    PA_LoadBackground(1, 1, &titre);
    if(PA_UserInfo.Language == 2) {
        PA_OutputText(0, 3, 6, "Le but est d'appuyer");
        PA_OutputText(0, 3, 7, "sur les boutons le");
        PA_OutputText(0, 3, 8, "plus vite possible.");
        PA_OutputText(0, 3, 9, "Quand vous appuyez sur");
        PA_OutputText(0, 3, 10, "un bouton, votre score");
        PA_OutputText(0, 3, 11, "augmente de un.");
        PA_OutputText(0, 3, 16, "Appuyez sur un bouton");
        PA_OutputText(0, 3, 17, "pour commencer !");
    }
    else {
        PA_OutputText(0, 3, 6, "The aim is to press the");
        PA_OutputText(0, 3, 7, "buttons as fast as you can.");
        PA_OutputText(0, 3, 8, "When a button is pressed,");
        PA_OutputText(0, 3, 9, "it add 1 point to");
        PA_OutputText(0, 3, 10, "your score.");
        PA_OutputText(0, 3, 16, "Press any button to start !");
    }
    PA_WaitFor(Pad.Newpress.Anykey || Stylus.Newpress);

    //Variables
    u32 coups = 0;

    //A vos marques, pret, partez !
    PA_ClearTextBg(0); //efface tout le texte du bas
    PA_VBLCounterStart(0); // compteur

    //A vos marques
    AS_SoundQuickPlay(un);
    PA_CreateSprite(0, 0, (void*)feu_Sprite, OBJ_SIZE_32X64, 1, 1, 200, 30); //feu, sprite 0
    if(PA_UserInfo.Language == 2) {
        PA_OutputText(0, 3, 6, "A vos marques...");
    }
    else {
        PA_OutputText(0, 3, 6, "Ready ?");
    }
    PA_WaitFor(PA_VBLCounter[0]/60 == 2);

    //Pret
    AS_SoundQuickPlay(deux);
    PA_SetSpriteAnim(0, 0, 2);
    if(PA_UserInfo.Language == 2) {
        PA_OutputText(0, 3, 8, "Prêt ?");
    }
    else {
        PA_OutputText(0, 3, 8, "Steady...");
    }
    PA_WaitFor(PA_VBLCounter[0]/60 == 4);


    //Partez
    AS_SoundQuickPlay(trois);
    PA_SetSpriteAnim(0, 0, 1);
    if(PA_UserInfo.Language == 2) {
        PA_OutputText(0, 3, 10, "Partez !");
    }
    else {
        PA_OutputText(0, 3, 10, "Go !");
    }
    PA_WaitFor(PA_VBLCounter[0]/60 == 6);

    PA_ClearTextBg(0); //efface tout le texte du bas
    PA_DeleteSprite(0, 0);
    PA_CreateSprite(0, 1, (void*)mario_Sprite, OBJ_SIZE_32X32, 1, 2, 100, 100); //mario, sprite 1 avec palette 2
    PA_CreateSprite(0, 2, (void*)boite_Sprite, OBJ_SIZE_16X16, 1, 3, 110, 84); //boite, sprite 2 avec palette 3
    PA_CreateSprite(0, 3, (void*)piece_Sprite, OBJ_SIZE_8X16, 1, 4, 114, 68); //boite, sprite 2 avec palette 3
    PA_VBLCounterStart(1); //compteur pour la partie à venir

    while(1) {
        PA_OutputText(0, 3, 7, "Score : %d", coups);
        if(PA_UserInfo.Language == 2) {
            PA_OutputText(0, 3, 6, "Partie en cours...");
            PA_OutputText(0, 3, 8, "Temps : %d ", 20-(PA_VBLCounter[1]/60));
        }
        else {
            PA_OutputText(0, 3, 6, "Game in progress...");
            PA_OutputText(0, 3, 8, "Time : %d ", 20-(PA_VBLCounter[1]/60));
        }
        //Incrémentation du score si la partie n'est pas fini
        if((Pad.Newpress.A || Pad.Newpress.B || Pad.Newpress.X || Pad.Newpress.Y || Pad.Newpress.L || Pad.Newpress.R || Stylus.Newpress || Pad.Newpress.Left || Pad.Newpress.Right || Pad.Newpress.Up || Pad.Newpress.Down) && PA_VBLCounter[1]/60 < 20) {
            PA_SetSpriteAnim(0, 1, 1); //fait sauter mario
            PA_SetSpriteAnim(0, 3, 1); //fait apparaitre une piece
            coups++;
        }

        //Lors du relachement des touches/stylet, les sprites reviennent a la normale
        if(Pad.Released.Anykey || Stylus.Released) {
            PA_SetSpriteAnim(0, 1, 0);//mario revient au sol
            PA_SetSpriteAnim(0, 3, 0); //et la piece disparait
        }

        //Fin de la partie
        if(PA_VBLCounter[1]/60 == 20) {
            //On efface le txt et les sprites
            PA_ClearTextBg(0);
            PA_DeleteSprite(0, 1);
            PA_DeleteSprite(0, 2);
            PA_DeleteSprite(0, 3);
            if(PA_UserInfo.Language == 2) {
                PA_OutputText(0, 3, 6, "Partie terminée !");
                PA_OutputText(0, 3, 7, "Votre score : %d", coups);
                PA_OutputText(0, 3, 9, "Appuyez sur une touche");
                PA_OutputText(0, 3, 10, "pour rejouer...");
            }
            else {
                PA_OutputText(0, 3, 6, "End of the game !");
                PA_OutputText(0, 3, 7, "Your score : %d", coups);
                PA_OutputText(0, 3, 9, "Press a button to");
                PA_OutputText(0, 3, 10, "replay...");
            }
            PA_WaitFor(PA_VBLCounter[1]/60 == 22);
            PA_WaitFor(Pad.Newpress.Anykey || Stylus.Newpress);
            goto accueil;
        }
        PA_CheckLid();
        PA_WaitForVBL();
    }

    return 0;
}