void StartScreen() { PA_LoadBackground(UP_SCREEN, BACKGROUND_UP, &UPSTARTSCREEN); PA_LoadSpritePal(DOWN_SCREEN, START_NUM, (void*) START_Pal); PA_CreateSprite(DOWN_SCREEN, START_NUM, (void*) START_Sprite, OBJ_SIZE_64X32, 1, START_NUM, 96, 50); PA_StartSpriteAnim(DOWN_SCREEN, START_NUM, 0, 1, 2); while (1) { PA_WaitForVBL(); if (Stylus.Newpress) { if (PA_SpriteTouched(START_NUM)) { PA_DeleteBg(UP_SCREEN, BACKGROUND_UP); PA_DeleteSprite(DOWN_SCREEN, START_NUM); PA_LoadBackground(UP_SCREEN, BACKGROUND_UP, &UPGAMESCREEN); PA_LoadBackground(DOWN_SCREEN, BACKGROUND_DOWN, &DOWNGAMESCREEN); break; } } if (Pad.Newpress.Start) { PA_DeleteBg(UP_SCREEN, BACKGROUND_UP); PA_DeleteSprite(DOWN_SCREEN, START_NUM); PA_LoadBackground(UP_SCREEN, BACKGROUND_UP, &UPGAMESCREEN); PA_LoadBackground(DOWN_SCREEN, BACKGROUND_DOWN, &DOWNGAMESCREEN); break; } } AS_SoundDefaultPlay((u8*)bgm, (u32)bgm_size, 127, 64, true, 0); }
// Fonction d'affichage du splashscreen void splash() { int i; // Timer //splash 1 : palib,devkitpro,"plus ou moins ds" PA_LoadBackground(1, 1, &splashtop); PA_LoadBackground(0, 1, &splashbottom); fonduentree(); for (i = 0; i < 60*3; i++) { if(Pad.Newpress.A || Stylus.Newpress) break; PA_WaitForVBL(); } fondusortie(); PA_ResetBgSys(); PA_ResetSpriteSys(); }
void initScreen() { PA_Init(); PA_LoadBackground(DOWN_SCREEN, BACKGROUND_DOWN, &start); PA_WaitForVBL(); }
int main(){ PA_Init(); // Initializes PA_Lib AS_Init(AS_MODE_SURROUND | AS_MODE_16CH); AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_SURROUND); PA_LoadBackground(UP_SCREEN, BACKGROUND_UP, &main_up); PA_LoadBackground(DOWN_SCREEN, BACKGROUND_DOWN, &main_down); create_tasks(); vTaskStartScheduler(); // Never returns while (1) ; return 0; }
/* 게임메인 */ int scr_Main() { /* 화면초기화 및 갱신 */ UnLoad_Screen(); PA_Init(); PA_InitVBL(); PA_LoadBackground(UP_SCREEN, BG1, &up_main); // 상단 디스플레이-타이틀화면 설정. PA_LoadBackground(DOWN_SCREEN, BG1, &down_main); // 하단 디스플레이-타이틀화면 설정. PA_LoadSpritePal(UP_SCREEN, BG2, (void*) GameName_Pal); PA_CreateSprite(UP_SCREEN, BG2, (void*) GameName_Sprite, OBJ_SIZE_64X32, 1, BG2, 74, 135); PA_StartSpriteAnim(UP_SCREEN, BG2, 0, 1, 1); PA_LoadSpritePal(DOWN_SCREEN, BG2, (void*) START_Pal); PA_CreateSprite(DOWN_SCREEN, BG2, (void*) START_Sprite, OBJ_SIZE_64X32, 1, BG2, 50, 100); PA_LoadSpritePal(DOWN_SCREEN, BG3, (void*) EXIT_Pal); PA_CreateSprite(DOWN_SCREEN, BG3, (void*) EXIT_Sprite, OBJ_SIZE_64X32, 1, BG3, 140, 100); if ( ismain==FALSE ) { AS_SoundDefaultPlay((u8*)start, (u32)start_size, 127, 64, TRUE, 0); ismain = TRUE; } while (1) { if (Stylus.Newpress) { if (PA_SpriteTouched(BG2)) { PA_DeleteBg(UP_SCREEN, BG1); PA_DeleteBg(DOWN_SCREEN, BG1); PA_DeleteSprite(DOWN_SCREEN, BG2); PA_DeleteSprite(DOWN_SCREEN, BG3); PA_DeleteSprite(UP_SCREEN, BG2); PA_LoadBackground(UP_SCREEN, BG1, &up); PA_LoadBackground(DOWN_SCREEN, BG1, &down); break; } if (PA_SpriteTouched(BG3)) { return GAMEEXIT; } } PA_WaitForVBL(); } return 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); // }
/* 메인 화면 */ int scr_Main() { UnLoad_Screen(); PA_Init(); PA_InitVBL(); PA_LoadBackground(UP_SCREEN, BG1, &up_main); // 상단 디스플레이-타이틀화면 설정. PA_LoadBackground(DOWN_SCREEN, BG1, &down_main); // 하단 디스플레이-타이틀화면 설정. PA_LoadSpritePal(UP_SCREEN, BG2, (void*) GameName_Pal); // 상단에 팔레트 생성 PA_CreateSprite(UP_SCREEN, BG2, (void*) GameName_Sprite, OBJ_SIZE_64X32, 1, BG2, 74, 140); PA_StartSpriteAnim(UP_SCREEN, BG2, 0, 1, 1);// 애니메이션 동작 실행 PA_LoadSpritePal(DOWN_SCREEN, BG2, (void*) START_Pal);// 하단에 START 팔레트 생성 PA_CreateSprite(DOWN_SCREEN, BG2, (void*) START_Sprite, OBJ_SIZE_64X32, 1, BG2, 55, 103); PA_LoadSpritePal(DOWN_SCREEN, BG3, (void*) EXIT_Pal);// 하단에 EXIT 팔레트 생성 PA_CreateSprite(DOWN_SCREEN, BG3, (void*) EXIT_Sprite, OBJ_SIZE_64X32, 1, BG3, 145, 103); AS_SoundDefaultPlay((u8*) start, (u32) start_size, 127, 64, TRUE, 0);//start 배경음 시작 while (1) { if (Stylus.Newpress) { // 화면이 눌렸을 때 if (PA_SpriteTouched(BG2)) {// BG2의 sprite 가 눌렸을 때(START) UnLoad_Sound(); UnLoad_Screen(); AS_SoundDefaultPlay((u8*) clk, (u32) clk_size, 50, 64, FALSE,0); PA_LoadBackground(UP_SCREEN, BG1, &up); PA_LoadBackground(DOWN_SCREEN, BG1, &down); break; // 화면의 출력된 모든 파일들 정리 후 일반 게임 배경 출력 후 break } if (PA_SpriteTouched(BG3)) // BG3의 sprite 가 눌렸을 때(EXIT) return GAMEEXIT; } PA_WaitForVBL(); } return 0; }
/* 게임 오버 */ 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프레임 유지 } }
/* 게임 오버 */ void scr_Gameover() { PA_Init(); PA_InitVBL(); UnLoad_Screen(); PA_LoadBackground(DOWN_SCREEN, BG1, &game_over); /* 종료스크린 출력*/ while (1) { if (Stylus.Newpress) { newGame = TRUE; // 새로운 게임. return; } PA_WaitForVBL(); // while문 안에 꼭 있어야함. 중요! } }
void mainScreen() { while (1) { if (Pad.Newpress.Start) { PA_DeleteBg(DOWN_SCREEN, BACKGROUND_DOWN); PA_DeleteSprite(DOWN_SCREEN, START_NUM); PA_LoadBackground(UP_SCREEN, BACKGROUND_UP, &map); break; } PA_WaitForVBL(); } }
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)) ); } }
// 싱글 플레이 스타트 void singleplay_start() { // 각각의 객체 생성 hero player; princess prin; monster mons1; water drop_water1; water drop_water2; water drop_water3; water drop_water4; crystal_Ball ball; // 랜덤으로 x좌표지정 drop_water1.x = PA_Rand()%250; drop_water2.x = PA_Rand()%250; drop_water3.x = PA_Rand()%250; drop_water4.x = PA_Rand()%250; mons1.x = PA_Rand()%250; // 각각의 객체 이미지 출력 // 물방울 그림 출력의 경우 (첫번째 인자 - spriteNUM, 두번째인자 - objNUM) drop_water1.water_setting(SPRITE2_PAL, OBJ2_NUM); drop_water2.water_setting(SPRITE3_PAL, OBJ3_NUM); drop_water3.water_setting(SPRITE4_PAL, OBJ4_NUM); drop_water4.water_setting(SPRITE5_PAL, OBJ5_NUM); ball.ball_setting(SPRITE6_PAL, OBJ6_NUM); mons1.monster_setting(SPRITE7_PAL, OBJ7_NUM, mons1.x); while(1) // 여기에서 게임이 동작!! { /* 텍스트 출력부분- 게임정보 (계속적으로 출력)*/ PA_OutputText(DOWN_SCREEN, 1, 21, "Stage%d", gp.stage_num); PA_OutputText(DOWN_SCREEN, 9, 21, "Score:%d", gp.score); PA_OutputText(DOWN_SCREEN, 18, 21, "Odd Monster:%d",gp.oddmonster); PA_OutputText(DOWN_SCREEN, 18, 22, "My Crystals:%d",gp.crystals); // 객체 이동 player.move(); prin.move(1); mons1.move(1); drop_water1.move(3); drop_water2.move(2); drop_water3.move(3); drop_water4.move(2); // 몬스터와 크리스탈이 충돌했을 때, if (PA_Distance(mons1.x, mons1.y, ball.x, ball.y) < 32*32) { gp.score = gp.score+50; mons1.y = mons1.y-100; // 몬스터가 뒤로 밀리는 현상 mons1.hp = mons1.hp-15; // 몬스터의 피가 15씩 감소 ball.x = -100; ball.y = -100; if(mons1.hp<0) { gp.oddmonster--; gp.score = gp.score+100; mons1.~monster(); } } // 물방울을 주인공이 먹었을 때 if (PA_Distance(drop_water1.x, drop_water1.y-240, player.x, player.y) < 16*8) { drop_water1.x = PA_Rand()%250; drop_water1.y = 0; gp.crystals++; } if(PA_Distance(drop_water2.x, drop_water2.y-240, player.x, player.y) < 16*8) { drop_water2.x = PA_Rand()%250; drop_water2.y = 0; gp.crystals++; } if(PA_Distance(drop_water3.x, drop_water3.y-240, player.x, player.y) < 16*8) { drop_water3.x = PA_Rand()%250; drop_water3.y = 0; gp.crystals++; } if(PA_Distance(drop_water4.x, drop_water4.y-240, player.x, player.y) < 16*8) { drop_water4.x = PA_Rand()%250; drop_water4.y = 0; gp.crystals++; } // 크리스탈 카운트 ( 떨어지는 물방울을 먹은 개수 만큼 볼 생성 ) if(gp.crystals > 0 ) gp.crystals = ball.move(player.x, gp.crystals); // 볼 생성 /******************************** Motion Area ****************************************/ move_sprite(SPRITE1, player.x, player.y); // hero 좌표 변경 후 출력 move_sprite(SPRITE9, prin.x, prin.y); // princess 좌표 변경 후 출력 dual_move(SPRITE2, drop_water1.x, drop_water1.y); // 물방울 좌표 변경 후 출력 dual_move(SPRITE3, drop_water2.x, drop_water2.y); // 물방울 좌표 변경 후 출력 dual_move(SPRITE4, drop_water3.x, drop_water3.y); // 물방울 좌표 변경 후 출력 dual_move(SPRITE5, drop_water4.x, drop_water4.y); // 물방울 좌표 변경 후 출력 if(mons1.y > 375) break; else dual_move(SPRITE7, mons1.x, mons1.y); // 몬스터 좌표 변경 후 출력 // 크리스탈 좌표 변경 후 출력 if(gp.crystals > 0) dual_move(SPRITE6, ball.x, ball.y); PA_WaitForVBL(); } UnLoad_Screen(); PA_LoadBackground(UP_SCREEN, BG2, &gameover); PA_LoadBackground(DOWN_SCREEN, BG2, &gameover); wait(100); }
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; }
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; }
/* 게임 */ 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); } }
/* 게임 */ 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(); } } }