Guest User

Untitled

a guest
Nov 5th, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. // Function: main()
  2. int main(int argc, char ** argv)
  3. {
  4. s16 i;
  5. PA_Init(); // Initializes PA_Lib
  6. PA_InitVBL(); // Initializes a standard VBL
  7. PA_InitRand();
  8. PA_InitText(0, 3);
  9. mmInitDefaultMem((mm_addr)soundbank_bin);
  10. mmLoad(MOD_MUSIC);
  11. mmLoadEffect(SFX_ALERT);
  12. mmLoadEffect(SFX_GAGNE);
  13. mmLoadEffect(SFX_SON_PIECE);
  14. mmSetModuleVolume(volume);
  15.  
  16.  
  17. fatInitDefault(); // initialisation de la FAT de la cartouche.
  18. save_file = fopen ("fat:cogito.sav", "rb"); //rb = read
  19. if(save_file==NULL)
  20. {
  21. save_file = fopen ("fat:cogito.sav", "wb");
  22. fonc_save(0);
  23. }
  24. else
  25. {
  26. fclose(save_file);
  27. fonc_load(0);
  28. }
  29.  
  30. PA_SetBrightness(0, -31); // all black
  31. PA_Init16bitBg(0, 3);
  32.  
  33. //Premier écran intro
  34. PA_Load16bitBitmap(0, intro1_Bitmap);
  35. for(i = 0; i < 60; i++) PA_WaitForVBL(); // Wait 2 second
  36. PA_SetBrightness(0, 0);
  37. mmEffect(SFX_ALERT);
  38. for(i = 0; i < 120; i++) PA_WaitForVBL(); // Wait 2 second
  39. for(i = 0; i > -32; i--)
  40. {
  41. PA_SetBrightness(0, i);
  42. PA_SetBrightness(1, i);
  43. PA_WaitForVBL();
  44. }
  45.  
  46. //Deuxième écran intro
  47. PA_Load16bitBitmap(0, intro2_Bitmap);
  48. for(i = -31; i <= 0; i++)
  49. {
  50. PA_SetBrightness(0, i);
  51. PA_SetBrightness(1, i);
  52. PA_WaitForVBL();
  53. }
  54. for(i = 0; i < 120; i++) PA_WaitForVBL(); // Wait 2 second
  55. for(i = 0; i > -32; i--)
  56. {
  57. PA_SetBrightness(0, i);
  58. PA_SetBrightness(1, i);
  59. PA_WaitForVBL();
  60. }
  61.  
  62.  
  63.  
  64. //Troisème écran intro
  65. mmStart(MOD_MUSIC, MM_PLAY_LOOP);//début de la musique.
  66. PA_Load16bitBitmap(0,intro3_Bitmap); // image
  67. for(i = 0; i < 90; i++) PA_WaitForVBL(); // Wait 1.5 second
  68. for(i = -31; i <= 0; i++)
  69. {
  70. PA_SetBrightness(0, i);
  71. PA_SetBrightness(1, i);
  72. PA_WaitForVBL();
  73.  
  74. }
  75.  
  76. while((!Pad.Newpress.Anykey) && (!Stylus.Newpress)) // On attend que le joueur touche l'écran ou qu'il appuye sur un bouton
  77. PA_WaitForVBL();
  78.  
  79. //Palettes des flèches.
  80. PA_LoadSpritePal(0,6,(void*)fleche_Pal); //type flèches 1
  81. PA_LoadSpritePal(0,9,(void*)fleche2_Pal); //type flèches 2
  82. for(i = 0; i > -32; i--)
  83. {
  84. PA_SetBrightness(0, i);
  85. PA_SetBrightness(1, i);
  86. PA_WaitForVBL();
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93. //Charge le tableaux des niveaux (niveaux/modèles/déplacement)
  94. charge_tab_niveaux();
  95.  
  96. while(MonNiveau<=MaxNiveau)
  97. {
  98. MonModele=Niveaux[0][MonNiveau];
  99. MonDeplacement=Niveaux[1][MonNiveau];
  100. tire_pionts();//Tirage des "couleurs" des 3 pions.
  101. Les_Modeles(0); //Chargement du Plateau et du Problème.
  102. Melange_plateau(99); //on mélange le plateau
  103. chargerdecor(0,0,0);
  104. Checkgagne=0;
  105. close=1;
  106. if(MonNiveau == 15 || MonNiveau == 25)
  107. {
  108. PA_EasyBgLoad(0, 1, bg);
  109. mmEffect(SFX_ALERT);
  110. for(i = 0; i < 180; i++) PA_WaitForVBL();
  111. PA_HideBg(0,1);
  112. }
  113. while(1)
  114. {
  115. if(Pad.Released.Start || PA_SpriteTouched(89)) // menu pause/save/load.
  116. fonc_menu_pause();
  117.  
  118. if(PA_CheckLid()) // Si on ferme la console allumée.
  119. {
  120. close++;
  121. PA_WaitForVBL(); // ???????????????????????????
  122. }
  123.  
  124. if (PA_SpriteTouched(127)) // on clique sur le bouton de changement de décor.
  125. {
  126. chargerdecor(1,1,0);
  127. PA_WaitFor(!Stylus.Held);
  128. }
  129.  
  130. if (PA_SpriteTouched(126)) // on clique sur le bouton "musique".
  131. musique();
  132.  
  133.  
  134.  
  135. for (i = 90; i <= 125; i++) // on clique sur une des fêches.
  136. {
  137. if (PA_SpriteTouched(i))
  138. {
  139. PA_SetSpriteAnim(0, i, 1);
  140. Bouge(i);
  141. mmEffect(SFX_SON_PIECE);
  142. PA_WaitFor(!Stylus.Held);
  143. PA_SetSpriteAnim(0, i, 0);
  144. }
  145. }
  146.  
  147. if(Checkgagne==1 || close==6 || loading==1) break;
  148. }
  149.  
  150. if(loading!=1)
  151. {
  152. mmEffect(SFX_GAGNE);
  153. MonNiveau++;
  154. }
  155. loading=2;
  156. for(i = 0; i > -32; i--)
  157. {
  158. PA_SetBrightness(0, i);
  159. PA_SetBrightness(1, i);
  160. PA_WaitForVBL();
  161. }
  162. }
  163. fonc_fin(); //FIN DU JEU
  164. return 0;
  165. } // End of main()
Advertisement
Add Comment
Please, Sign In to add comment