Exemple #1
0
void dropshipCreate(mapTile map[][MAX_MAP_Y_LENGTH]){
	u8 i, j;
	u8 x, y;
	for(i=0; i<fireCount; i++)
		PA_DeleteSprite(DOWN_SCREEN, FIREINMAP + i);
	for(i=0; i<MAX_MAP_X_LENGTH; i++)
		for(j=0; j<MAX_MAP_Y_LENGTH; j++)
		{
			if (i != 0 && i != (MAX_MAP_X_LENGTH - 1) && j != 0
								&& j != (MAX_MAP_Y_LENGTH - 1))
			map[i][j].state = MAP_STATE_NULL;
		}
	x = MAX_MAP_X_LENGTH / 2 - 2;
	y = MAX_MAP_Y_LENGTH / 2 - 2;
	PA_LoadSpritePal(DOWN_SCREEN, DROPSHIP_PAL, (void*) dropship_Pal);
	PA_CreateSprite(DOWN_SCREEN, DROPSHIP, (void*) dropship_Sprite, OBJ_SIZE_64X64, TRUE,
			DROPSHIP_PAL,  map[x][y].x, map[x][y].y);
	PA_StartSpriteAnimEx (DOWN_SCREEN, DROPSHIP, 0, 4, 3, ANIM_UPDOWN, -1);
	for(i=1; i<3; i++)
		for(j=1; j<3; j++)
			map[x+i][y+j].state = MAP_STATE_EXIT;
	AS_SoundQuickPlay(dropship);
}
Exemple #2
0
portTASK_FUNCTION(Unit_Task, pvParameters ) {
	body bd[MAX_BODY_LENGTH];
	int i;
	u8 x = 5;
	u8 y = 5;
	unit.x = 5;
	unit.y = 5;
	u8 pfx;
	u8 pfy;
	u8 pfDirection;
	u8 tempx;
	u8 tempy;
	u8 tempDirection;
	unit.direction = D_DOWN;
	portTickType xLastWakeTime = xTaskGetTickCount();
	PA_LoadSpritePal(DOWN_SCREEN, C_PAL, (void*) C_Pal);
	PA_LoadSpritePal(DOWN_SCREEN, BODY_PAL, (void*) man_Pal);
	PA_CreateSprite(DOWN_SCREEN, C, (void*) C_Sprite, OBJ_SIZE_32X32, TRUE,
			C_PAL,  map[unit.x][unit.y].x-8, map[unit.x][unit.y].y-16);

	while (1) {
		x = unit.x;
		y = unit.y;
		switch (unit.direction) {
		case D_UP:
			y--;
			break;
		case D_DOWN:
			y++;
			break;
		case D_LEFT:
			x--;
			break;
		case D_RIGHT:
			x++;
			break;
		default:
			break;
		}
		if ((map[x][y].state == MAP_STATE_NULL)
				|| (map[x][y].state == MAP_STATE_ITEM)) {
			pfx = unit.x;
			pfy = unit.y;
			pfDirection = unit.direction;
			if ((map[x][y].state == MAP_STATE_ITEM)) {
				if (length < MAX_BODY_LENGTH) // to max length
				{
					length++;
					fireCreate(map);
				}
				if (length == MAX_BODY_LENGTH)
				{
					dropshipCreate(map);
				}
				map[x][y].state = MAP_STATE_NULL;
				PA_StopSpriteAnim(DOWN_SCREEN,map[x][y].itemSpriteNum);
				PA_DeleteSprite(DOWN_SCREEN, map[x][y].itemSpriteNum);
				PA_CreateSprite(DOWN_SCREEN, BODY + (length-1), (void*) man_Sprite,
					OBJ_SIZE_16X32, TRUE, BODY_PAL, 0, 0);
			}
			unit.x = x;
			unit.y = y;
			PA_SetSpriteXY(DOWN_SCREEN, C, map[unit.x][unit.y].x - 8,
					map[unit.x][unit.y].y - 16);
			for (i = 0; i < length; i++) {
				tempx = bd[i].x;
				tempy = bd[i].y;
				tempDirection = bd[i].direction;
				map[tempx][tempy].state = MAP_STATE_NULL;
				bd[i].x = pfx;
				bd[i].y = pfy;
				map[pfx][pfy].state = MAP_STATE_C_BODY;
				bd[i].direction = pfDirection;
				pfx = tempx;
				pfy = tempy;
				pfDirection = tempDirection;
				PA_SetSpriteXY(DOWN_SCREEN, BODY + i, map[bd[i].x][bd[i].y].x,
						(map[bd[i].x][bd[i].y].y)-16);
				if(pfDirection!=bd[i].direction)
					PA_StartSpriteAnim(DOWN_SCREEN, BODY + i, bd[i].direction, bd[i].direction+2, 7);
			}
		}
		if((map[x][y].state == MAP_STATE_WALL) || map[x][y].state == MAP_STATE_C_BODY) //실패
		{
			AS_SoundQuickPlay(die);
			PA_ResetSpriteSys ();
			PA_ResetBgSysScreen (DOWN_SCREEN);
			PA_LoadBackground(DOWN_SCREEN, 3, &FAILSCREEN);
			vTaskSuspend(NULL);
		}
		if(map[x][y].state == MAP_STATE_EXIT)      //클리어
		{
			PA_ResetSpriteSys ();
			PA_ResetBgSysScreen (DOWN_SCREEN);
			PA_LoadBackground(DOWN_SCREEN, 3, &CLEARSCREEN);
			vTaskSuspend(NULL);
		}
		vTaskDelayUntil(&xLastWakeTime, MSEC2TICK(300-(length*10)) );
	}
}
Exemple #3
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;
}
Exemple #4
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;
}