Ejemplo n.º 1
0
void displayPercentages() {
	PA_OutputText(SUB_SCREEN, 0, 0, "                                           ");
	PA_OutputText(SUB_SCREEN, 0, 23, "                                           ");
	// clears the text
	if(players.size() >=1) {
		PA_SetTextTileCol(SUB_SCREEN, TEXT_RED);
		int damage = (int)(players[0]->getDamagePercent());
		PA_OutputText(SUB_SCREEN, 0, 0, "%d %", damage);
	} // displays damage percent of player 1
	if(players.size() >= 2) {
		PA_SetTextTileCol(SUB_SCREEN, TEXT_BLUE);
		int damage = (int)(players[1]->getDamagePercent());
		stringstream ss;
		ss << damage;
		int length = ss.str().size();
		PA_OutputText(SUB_SCREEN, 30-length, 0, "%d %", damage);
	} // displays damage percent of player 2
	if(players.size() >= 3) {
		PA_SetTextTileCol(SUB_SCREEN, TEXT_YELLOW);
		int damage = (int)(players[2]->getDamagePercent());
		PA_OutputText(SUB_SCREEN, 0, 23, "%d %", damage);
	} // damage of player 3
	if(players.size() >= 4) {
		PA_SetTextTileCol(SUB_SCREEN, TEXT_GREEN);
		int damage = (int)(players[3]->getDamagePercent());
		stringstream ss;
		ss << damage;
		int length = ss.str().size();
		PA_OutputText(SUB_SCREEN, 30-length, 23, "%d %", damage);
	}
} // displays damage percents on the sub screen
Ejemplo n.º 2
0
void displayLives(int stock) {
	PA_OutputText(SUB_SCREEN, 0, 1, "                                               ");
	PA_OutputText(SUB_SCREEN, 0, 22, "                                               ");
	if(players.size() >= 1) {
		PA_SetTextTileCol(SUB_SCREEN, TEXT_RED);
		int lives = stock - score.getDeaths(0) - sdcost*score.getSDs(0);
		PA_OutputText(SUB_SCREEN, 0, 1, "x%d", lives);
	}
	if(players.size() >= 2) {
		PA_SetTextTileCol(SUB_SCREEN, TEXT_BLUE);
		int lives = stock-score.getDeaths(1) - sdcost*score.getSDs(1);
		stringstream ss;
		ss << lives;
		int length = ss.str().size();
		PA_OutputText(SUB_SCREEN, 31-length, 1, "x%d", lives);
	}
	if(players.size() >= 3) {
		PA_SetTextTileCol(SUB_SCREEN, TEXT_YELLOW);
		int lives = stock-score.getDeaths(2) - sdcost*score.getSDs(2);
		PA_OutputText(SUB_SCREEN, 0, 22, "x%d", lives);
	}
	if(players.size() >= 4) {
		PA_SetTextTileCol(SUB_SCREEN, TEXT_GREEN);
		int lives = stock-score.getDeaths(3) - sdcost*score.getSDs(3);
		stringstream ss;
		ss << lives;
		int length = ss.str().size();
		PA_OutputText(SUB_SCREEN, 31-length, 22, "x%d", lives);
	}
}
Ejemplo n.º 3
0
/**
Treu el text passat per la sortida configurada al debug o en cas d'estar 
desactivat no fa res
*/
void debug(char *text) {
	if(!debug_mode) return;
	if(debug_mode==DEBUG_SOCKET) {
		send(debug_socket,text,strlen(text),0);
		/*if(errno!=EWOULDBLOCK) {
			error("S'hauria de bloquejar");
		}
		*/
	} else if (debug_mode==DEBUG_DISPLAY) {
		PA_SetTextTileCol(TOP_SCREEN,PINK);
		PA_Print(TOP_SCREEN,text);
		PA_SetTextTileCol(TOP_SCREEN,NORMAL);
	}
}
Ejemplo n.º 4
0
/**
Inicialitza el debug:
 mode: DEBUG_SOCKET 1, DEBUG_DISPLAY
 El mode assigna el display o un socket a la sortida de missatges.
 En cas de seleccionar un socket, es posa en mode escolta al port 7773 
esperant una conexió
*/
void debug_init(u8 mode) {
	int wait;
	debug_mode=mode;
	if(mode==DEBUG_SOCKET) {
		PA_SetTextTileCol(TOP_SCREEN,PINK);
		PA_Print(TOP_SCREEN,"Esperant client al port 7773\n");
		PA_SetTextTileCol(TOP_SCREEN,NORMAL);
		listen_sock=listensock(7773, 1);
		debug_socket=acceptsock(listen_sock);
		closesocket(listen_sock);
		wait=DONTWAIT;
		ioctl(debug_socket,FIONBIO,&wait);
	}
	debug("Debug inicialitzat\n");
}
Ejemplo n.º 5
0
// 싱글 플레이 초기화
void init_singleplay() {
 PA_LoadBackground(DOWN_SCREEN, BG2, &bg_stage1_init);
 PA_WaitForVBL();
 //UnLoad_Screen();
 //PA_WaitForVBL();
 ret_next(); // next state
 dualback_print(&stage2); // 게임배경화면 출력 (듀얼)

 /* 텍스트 출력 부분 */
 PA_InitText(DOWN_SCREEN, BG0);
 PA_SetTextTileCol(DOWN_SCREEN, TEXT_WHITE); //
}
Ejemplo n.º 6
0
Archivo: main.c Proyecto: hl1itj/Team8
/* 게임 오버 */
void scr_Gameover() {
	int weight = 0;
	PA_Init();
	PA_InitVBL();
	UnLoad_Screen();
	AS_SoundDefaultPlay((u8*) wrong, (u32) wrong_size, 100, 64, FALSE, 0);
	AS_SoundDefaultPlay((u8*) gameover, (u32) gameover_size, 80, 64, TRUE, 0);
	PA_LoadBackground(UP_SCREEN, BG3, &your_brain); // 종료스크린 출력
	PA_LoadBackground(DOWN_SCREEN, BG3, &game_over);
	PA_InitText(UP_SCREEN, BG1);
	PA_SetTextTileCol(UP_SCREEN, TEXT_BLACK);
	weight = ((uinfo.userStage * 1000 ) + uinfo.userScore) / 3;
	PA_OutputText(UP_SCREEN, 10, 12, "%d.%d g", weight / 100, weight % 100);

	while (1) {
		if (Stylus.Newpress) {
			UnLoad_Sound();
			newGame = TRUE; // 새로운 게임.
			return;
		}
		PA_WaitForVBL(); // 60프레임 유지
	}
}
Ejemplo n.º 7
0
int main()
{
	int heroX=0;
	srand(time(NULL));
	Dong dong1={rand()%255,0};
	Dong dong2={rand()%255,0};
	Dong dong3={rand()%255,0};
	Dong dong4={rand()%255,0};
	Dong dong5={rand()%255,0};
	Dong dong6={rand()%255,0};
	Dong dong7={rand()%255,0};


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

	PA_InitSound();
	PA_PlayMod(modfile);



	// Infinite loop to keep the program running
	while (1)
	{
		int score=0;
		static int scoreRank1=0, scoreRank2=0, scoreRank3=0;
		PA_EasyBgLoad(UP_SCREEN, BG2, mainup);
		PA_EasyBgLoad(DOWN_SCREEN, BG2, Menu);

		int selnum=0;

		selnum = sel_menu();


		if(selnum == 1){
GAMESTART:
			//��������
			PA_EasyBgLoad(UP_SCREEN, BG2, backgroundUp);
			PA_EasyBgLoad(DOWN_SCREEN, BG2, backgroundDown);
			PA_WaitForVBL();
			//ij���� ����
			PA_LoadSpritePal(DOWN_SCREEN,0,(void*)frames_Pal);
			PA_CreateSprite(DOWN_SCREEN,0,(void*)frames_Sprite, OBJ_SIZE_16X32, 1, 0, 128-16, 192-32);

			PA_DualLoadSpritePal(2,(void*)dong_Pal);
			PA_DualLoadSpritePal(3,(void*)dong_Pal);
			PA_DualLoadSpritePal(4,(void*)dong_Pal);
			PA_DualLoadSpritePal(5,(void*)dong_Pal);
			PA_DualLoadSpritePal(6,(void*)dong_Pal);
			PA_DualLoadSpritePal(7,(void*)dong_Pal);
			PA_DualLoadSpritePal(8,(void*)dong_Pal);

			PA_DualCreateSprite(2,(void*)dong_Sprite, OBJ_SIZE_16X16,1,2,0,0);
			PA_DualCreateSprite(3,(void*)dong_Sprite, OBJ_SIZE_16X16,1,3,0,0);
			PA_DualCreateSprite(4,(void*)dong_Sprite, OBJ_SIZE_16X16,1,4,0,0);
			PA_DualCreateSprite(5,(void*)dong_Sprite, OBJ_SIZE_16X16,1,5,0,0);
			PA_DualCreateSprite(6,(void*)dong_Sprite, OBJ_SIZE_16X16,1,6,0,0);
			PA_DualCreateSprite(7,(void*)dong_Sprite, OBJ_SIZE_16X16,1,6,0,0);
			PA_DualCreateSprite(8,(void*)dong_Sprite, OBJ_SIZE_16X16,1,6,0,0);

			/* �ؽ�Ʈ ���� �κ� */
			PA_InitText(UP_SCREEN, BG0);
			PA_SetTextTileCol(UP_SCREEN, 9);

			PA_OutputText(DOWN_SCREEN, 1, 21, "test");
			
			//PA_DualSetSpriteAnim(2,2);
			//PA_DualSetSpriteAnim(3,3);

			while(true){
				if(Pad.Held.Right && heroX<256-16){
					PA_SetSpriteAnim(0,0,1);
					heroX+=10;
				}
				if(Pad.Held.Left && heroX>0){
					PA_SetSpriteAnim(0,0,3);
					heroX-=10;
				}
				PA_SetSpriteXY(DOWN_SCREEN,0,heroX,192-32);
				PA_WaitForVBL();
				//---------------------------------------------------------------
				dong1.y+=10;
				if(dong1.y>410){
					score+=100;
					dong1.y=0;
					dong1.x =rand()%255;

				}
				dong2.y+=11;
				if(dong2.y>410){
					score+=100;
					dong2.y=0;
					dong2.x =rand()%255;

				}
				dong3.y+=12;
				if(dong3.y>410){
					score+=100;
					dong3.y=0;
					dong3.x =rand()%255;

				}
				dong4.y+=13;
				if(dong4.y>410){
					score+=100;
					dong4.y=0;
					dong4.x =rand()%255;

				}
				dong5.y+=14;
				if(dong5.y>410){
					score+=100;
					dong5.y=0;
					dong5.x =rand()%255;

				}
				dong6.y+=15;
				if(dong6.y>410){
					score+=100;
					dong6.y=0;
					dong6.x =rand()%255;

				}
				dong7.y+=16;
				if(dong7.y>410){
					score+=100;
					dong7.y=0;
					dong7.x =rand()%255;

				}
				PA_OutputText(UP_SCREEN, 0, 0, "score = %d",score);


				PA_WaitForVBL();
				PA_DualSetSpriteXY(2,dong1.x,dong1.y);
				PA_WaitForVBL();
				PA_DualSetSpriteXY(3,dong2.x,dong2.y);
				PA_WaitForVBL();
				PA_DualSetSpriteXY(4,dong3.x,dong3.y);
				PA_WaitForVBL();
				PA_DualSetSpriteXY(5,dong4.x,dong4.y);
				PA_WaitForVBL();
				PA_DualSetSpriteXY(6,dong5.x,dong5.y);
				PA_WaitForVBL();
				PA_DualSetSpriteXY(7,dong6.x,dong6.y);
				PA_WaitForVBL();
				PA_DualSetSpriteXY(8,dong7.x,dong7.y);

				if(dong1.y>390 && (heroX+16)>dong1.x && heroX<(dong1.x+16))
					break;
				if(dong2.y>390 && (heroX+16)>dong2.x && heroX<(dong2.x+16))
					break;
				if(dong3.y>390 && (heroX+16)>dong3.x && heroX<(dong3.x+16))
					break;
				if(dong4.y>390 && (heroX+16)>dong4.x && heroX<(dong4.x+16))
					break;
				if(dong5.y>390 && (heroX+16)>dong5.x && heroX<(dong5.x+16))
					break;
				if(dong6.y>390 && (heroX+16)>dong6.x && heroX<(dong6.x+16))
					break;
				if(dong7.y>390 && (heroX+16)>dong7.x && heroX<(dong7.x+16))
					break;



			}
			PA_WaitForVBL();
			PA_EasyBgLoad(UP_SCREEN, BG2, gameoverUp); //����ȭ�� gameover
			PA_EasyBgLoad(DOWN_SCREEN, BG2, gameoverDown); //����ȭ�� gameover
			PA_DeleteSprite(DOWN_SCREEN, 0); //���� ������
			PA_DualDeleteSprite(2);  //��������
			PA_DualDeleteSprite(3);  //��������
			PA_DualDeleteSprite(4);  //��������
			PA_DualDeleteSprite(5);  //��������
			PA_DualDeleteSprite(6);  //��������
			PA_DualDeleteSprite(7);  //��������
			PA_DualDeleteSprite(8);  //��������
			PA_InitText(UP_SCREEN, BG0); //�ؽ�Ʈ �ʱ�ȭ
			PA_SetTextTileCol(UP_SCREEN, 9); //�ؽ�Ʈ �� ������ ����
			PA_OutputText(UP_SCREEN, 10, 13, "score = %d",score);
			ret_next(); //�Է´���
			
			//--------�ʱ�ȭ
			if(score>=scoreRank1){ //1��
				scoreRank3=scoreRank2;
				scoreRank2=scoreRank1;
				scoreRank1=score;
			}
			else if(score>=scoreRank2){//2��
				scoreRank3=scoreRank2;
				scoreRank2=score;
			}
			else if(score>=scoreRank3){//3��
				scoreRank3=score;
			}
			score=0;
			dong1.x=rand()%255; dong1.y=0;
			dong2.x=rand()%255; dong2.y=0;
			dong3.x=rand()%255; dong3.y=0;
			dong4.x=rand()%255; dong4.y=0;
			dong5.x=rand()%255; dong5.y=0;
			dong6.x=rand()%255; dong4.y=0;
			dong7.x=rand()%255; dong5.y=0;
			PA_InitText(UP_SCREEN, BG0); //�ؽ�Ʈ �ʱ�ȭ
			PA_WaitForVBL();


		}
		else if(selnum == 2){ //��ũ ȭ��
			PA_WaitForVBL();
			PA_EasyBgLoad(UP_SCREEN, BG2, rankingUp); //����ȭ�� rankingUp
			PA_EasyBgLoad(DOWN_SCREEN, BG2, rankingDown); //����ȭ�� rankingDown
			PA_InitText(UP_SCREEN, BG0); //�ؽ�Ʈ �ʱ�ȭ
			PA_SetTextTileCol(UP_SCREEN, 9); //�ؽ�Ʈ �� ������ ����
			PA_OutputText(UP_SCREEN, 10, 13, "Rank 1! = %d",scoreRank1);
			PA_OutputText(UP_SCREEN, 10, 15, "Rank 2! = %d",scoreRank2);
			PA_OutputText(UP_SCREEN, 10, 17, "Rank 3! = %d",scoreRank3);
			ret_next(); //�Է´���
			PA_InitText(UP_SCREEN, BG0); //�ؽ�Ʈ �ʱ�ȭ
			goto GAMESTART;


		}
		else
			;
		PA_WaitForVBL();
	}

	return 0;
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
Archivo: main.c Proyecto: hl1itj/Team8
/* 게임 */
void scr_Game() {
	/* 타이머 변수_초. */
	int lastcount;      // 이전 초.
	int currentcount;   // 현재 초.
	u8 pressed = FALSE;

	PA_Init();
	PA_InitVBL();

	PA_LoadBackground(UP_SCREEN, BG3, &up); // 상단 디스플레이-타이틀화면 설정.
	PA_LoadBackground(DOWN_SCREEN, BG3, &down); // 하단 디스플레이-타이틀화면 설정.
	PA_InitText(UP_SCREEN, BG2);
	PA_SetTextTileCol(UP_SCREEN, TEXT_BLACK);
	/* 배경음악 플레이 */
	if ( isplaying==FALSE ) {
			UnLoad_Sound();
			AS_SoundDefaultPlay((u8*)bgm, (u32)bgm_size, 127, 64, TRUE, 0);
			isplaying = TRUE;
		}

	while (1) {
		int i;
		status = 0;
		lastcount = currentcount = 0;
		stageTime = 30;		    // 스테이지  제한시간
		memoryTime = 10;
		scr_Stage(uinfo.userStage);

		PA_OutputText(UP_SCREEN, 10, 2, "Stage :  %d", uinfo.userStage);
		PA_OutputText(UP_SCREEN, 10, 5, "Score :  %d", uinfo.userScore);
		PA_OutputText(UP_SCREEN, 10, 7, "Time  :  %d", memoryTime);

		PA_LoadSpritePal(UP_SCREEN, BLOCKPAL, (void*) Block_Pal);	// 블럭 정보 스프라이트 팔레트
		PA_LoadSpritePal(DOWN_SCREEN, BLOCKPAL, (void*) Block_Pal); // 게임 블럭 스프라이트 팔레트

		for( i = 0; i < 5; i++){
		PA_CreateSprite(UP_SCREEN, i, (void*) Block_Sprite, OBJ_SIZE_32X32, 1,
				BLOCKPAL, (40*i)+32, 135);
		PA_SetSpriteAnim(UP_SCREEN, i, i);
		}

		view_block(); //블럭 보여줌
		PA_VBLCountersReset(); // 카운터 초기화.
		PA_VBLCounterStart(0); // 카운터 시작.

		while (1) { // 보여주는 시간
			/* 카운터 초기화 및 시작 */
			currentcount = (PA_VBLCounter[0] / 60);
			if (lastcount != currentcount) {
				memoryTime -= (currentcount - lastcount);
				lastcount = currentcount;
				PA_ClearTextBg(UP_SCREEN);
				PA_OutputText(UP_SCREEN, 10, 2, "Stage :  %d", uinfo.userStage);
				PA_OutputText(UP_SCREEN, 10, 5, "Score :  %d", uinfo.userScore);
				PA_OutputText(UP_SCREEN, 10, 7, "Time  :  %d", memoryTime);
			}
			if(memoryTime == 0){
				block_init(); // 블럭 초기화
				break ; // 0이하가 되면 본게임으로
			}
			PA_WaitForVBL();
		}
		//vTaskResume(Touch_Task);
		PA_OutputText(UP_SCREEN, 10, 7, "Time  :  %d", stageTime);
		while (1) { //일단 잘못 누르면 게임 오버로 만들기.
			//버튼 인식 받고 그 정보로 메모리 성공, 실패, 게임중 선택 하는 함수 추가
			/* 카운터 초기화 및 시작 */
			currentcount = (PA_VBLCounter[0] / 60);
			if (lastcount != currentcount) {
				stageTime -= (currentcount - lastcount);
				lastcount = currentcount;
				PA_ClearTextBg(UP_SCREEN);
				PA_OutputText(UP_SCREEN, 10, 2, "Stage :  %d", uinfo.userStage);
				PA_OutputText(UP_SCREEN, 10, 5, "Score :  %d", uinfo.userScore);
				PA_OutputText(UP_SCREEN, 10, 7, "Time  :  %d", stageTime);
			}
			if (stageTime == 0 || status == 1)
				return; //게임 나가기
			if (Stylus.Newpress) {
				for (i = 0; i < 16; i++) {
					if ((pressed == FALSE) && PA_SpriteTouched(i)) {
						status = block_reload(i);
						pressed = TRUE;
					} else if ((pressed == TRUE) && !PA_SpriteTouched(i)) {
						pressed = FALSE;
					}
				}
			}
			if(check_win()){
				++uinfo.userStage;
				break;
			}
			PA_WaitForVBL();
		}
		vTaskSuspend(Touch_Task);
	}
}
Ejemplo n.º 11
0
Archivo: main.c Proyecto: hl1itj/Team8
/* 게임 */
void scr_Game() {
	int lastcount; 		// 이전 초
	int currentcount;	// 현재 초

	PA_Init();
	PA_InitVBL();

	AS_SoundDefaultPlay((u8*) bgm, (u32) bgm_size, 127, 64, TRUE, 0);

	while (1) {
		int i;
		lastcount = currentcount = 0;
		stageTime = 30; // 스테이지  제한시간
		memoryTime = 10;
		UnLoad_Screen();

		PA_LoadBackground(UP_SCREEN, BG3, &up); 	// 상단 디스플레이-타이틀화면 설정.
		PA_LoadBackground(DOWN_SCREEN, BG3, &down); // 하단 디스플레이-타이틀화면 설정.
		PA_InitText(UP_SCREEN, BG2);
		PA_SetTextTileCol(UP_SCREEN, TEXT_RED);

		userBlock_init();
		scr_Stage(uinfo.userStage);
		Memory_info();
		PA_LoadSpritePal(UP_SCREEN, BLOCKPAL, (void*) Block_Pal); 	// 블럭 정보 스프라이트 팔레트
		PA_LoadSpritePal(DOWN_SCREEN, BLOCKPAL, (void*) Block_Pal); // 게임 블럭 스프라이트 팔레트

		for (i = 0; i < 5; i++) { // 위 화면에 블럭의 변화를 보여주는 sprite 생성
			PA_CreateSprite(UP_SCREEN, i, (void*) Block_Sprite, OBJ_SIZE_32X32,
					1, BLOCKPAL, (40 * i) + 32, 135);
			PA_SetSpriteAnim(UP_SCREEN, i, i);
		}

		view_block();
		PA_VBLCountersReset(); // 카운터 초기화.
		PA_VBLCounterStart(0); // 카운터 시작.

		while (1) {
			currentcount = (PA_VBLCounter[0] / 60);
			if (lastcount != currentcount) { // 메모리 타임 체크
				memoryTime -= (currentcount - lastcount);
				lastcount = currentcount;
				Memory_info();
			}
			if (memoryTime == 0) { // 0이하가 되면 본게임으로
				AS_SoundDefaultPlay((u8*) blind, (u32) blind_size, 80, 64, FALSE,0);
				PA_DeleteSprite(DOWN_SCREEN, BLOCKPAL);
				block_init(); // 블럭 초기화
				break;
			}
			if (NDS_SWITCH() == KEY_START)
				memoryTime = 0;
			PA_WaitForVBL();
		}

		Gaming_info();

		while (1) {
			currentcount = (PA_VBLCounter[0] / 60);
			if (lastcount != currentcount) { // 게임 시간 체크
				stageTime -= (currentcount - lastcount);
				lastcount = currentcount;
				Gaming_info();
			}
			if (stageTime <= 0) { //게임 나가기
				UnLoad_Sound();
				return;
			}
			if (Stylus.Newpress) {
				for (i = 0; i < BLOCKS_NUM; i++){
					if (PA_SpriteTouched(i)) block_reload(i);
				}
			}
			if (check_clear()) { 	// 게임 진행 상태 체크
				uinfo.userStage++; // 스테이지 업
				AS_SoundDefaultPlay((u8*) stageup, (u32) stageup_size, 45, 64, FALSE,0);
				break;
			}
			PA_WaitForVBL();
		}
	}
}