Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.05 KB | None | 0 0
  1. /*------------------------------------------
  2. Parachute remake for Makebuino
  3. v0.1 by Jicehel Date:05/08/017
  4. Based on Nintendo Game & Watch Paachute
  5. Thanks to Luis Dominguez - LADBSoft.com
  6. for the examples with “Firebuino”
  7. ------------------------------------------*/
  8. #include <Gamebuino.h>
  9. #include <EEPROM.h>
  10. #include <SPI.h>
  11. Gamebuino gb;
  12.  
  13. long score;
  14. long highscore;
  15. short misses;
  16. short BoatPosition;
  17. short moveTick;
  18. short spawnDelay;
  19. short noParachutes;
  20. short randNo;
  21. short shark_anim;
  22. byte gameState;
  23. short x;
  24.  
  25. const byte barque_p1[] PROGMEM = { 8,7,
  26. B00111000,B01011100,B01111000,B00110000,B11011100,B11111111,B11001111,};
  27.  
  28. const byte barque_p2[] PROGMEM = { 8,7,
  29. B00000000,B00000000,B00000000,B00000000,B00000000,B11111111,B11111110,};
  30.  
  31. const byte requin_p1[] PROGMEM = { 8,6,
  32. B00000000,B11000001,B11110110,B11111111,B01111110,B11111111,B00000000,B00000000,};
  33.  
  34. const byte requin_p2[] PROGMEM = { 5,6,
  35. B00111000,B11111000,B11010000,B10000000,B00110000,B11110000,};
  36.  
  37. const byte aileron[] PROGMEM =
  38. {
  39. 8,8,
  40. B00010000,
  41. B01110000,
  42. B01110000,
  43. B11110000,
  44. B00000000,
  45. B00000000,
  46. B00000000,
  47. B00000000,
  48. };
  49.  
  50. const byte subBackgroundBitmap[] PROGMEM = {88,48,
  51. B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00010000,
  52. B11101001,B10001000,B10110101,B01111011,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  53. B10110101,B01010101,B01110101,B01010010,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  54. B11011101,B10011101,B00111101,B01010011,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  55. B10010101,B01010101,B01110101,B01010010,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  56. B10010101,B01010100,B10110101,B11010011,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  57. B00000000,B00000000,B00100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  58. B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  59. B00011010,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  60. B01101110,B10100111,B11000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  61. B11111111,B11111111,B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  62. B11111111,B11111111,B11111100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  63. B01111111,B11111101,B01110100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  64. B11111111,B01001000,B00010000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000100,B10110000,
  65. B10011100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B11001101,B10110000,
  66. B00011000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011110,B11111111,B11110000,
  67. B00111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01111111,B11111111,B11110000,
  68. B00110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B11111111,B11111111,B11110000,
  69. B01110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000010,B01111111,B01111111,B11100000,
  70. B01100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000100,B11111011,B10110000,
  71. B01100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B11111001,B11000000,
  72. B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B10101000,B11000000,
  73. B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00100000,B11100000,
  74. B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11110000,
  75. B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11110000,
  76. B11110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000111,B11110000,
  77. B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,B11110000,
  78. B11111111,B10000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11110000,
  79. B11111111,B10000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11111111,B11110000,
  80. B11111111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11111111,B11110000,
  81. B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11111111,B11110000,
  82. B11111100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000111,B11110000,
  83. B11111100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B11110000,
  84. B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B11110000,
  85. B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11110000,
  86. B11111000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B11110000,
  87. B11111000,B00000000,B00000000,B00000000,B00000000,B00111000,B00000000,B00000000,B00000000,B00000000,B01110000,
  88. B11110000,B11110011,B00011110,B01100001,B11111001,B11111100,B11001111,B11100000,B00010000,B00100000,B11110000,
  89. B00000000,B00000100,B00000000,B00000000,B00000000,B01000000,B00000000,B00110000,B00000000,B00000000,B00000000,
  90. B11100000,B10000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,
  91. B00001110,B00000000,B00000000,B00000000,B00000000,B00001000,B00000000,B00000011,B11110001,B11000011,B11100000,
  92. B11110001,B11100000,B00000000,B00000000,B00000000,B00001000,B00000000,B00000000,B00001111,B00111111,B00000000,
  93. B00001110,B00000000,B00000000,B01111100,B00001111,B00111110,B00000000,B00000000,B00000000,B11000000,B00000000,
  94. B11000000,B01111100,B00000000,B00000000,B00000000,B00001000,B00000000,B00000000,B00000000,B00000001,B11110000,
  95. B00000000,B00000000,B00000000,B00000000,B00000000,B00001000,B00000000,B00000000,B00000000,B00000000,B00000000,
  96. B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00110000,
  97. B00000000,B00000001,B11111001,B11100001,B11110011,B11000111,B11111100,B00001111,B10000000,B00000000,B00000000,
  98. B10000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00010000,};
  99.  
  100. void titleScreen() {
  101. // gb.titleScreen(F(“Parachute”), titleScreenBitmap);
  102. gb.titleScreen(F("Parachute"));
  103. gb.battery.show = false;
  104. }
  105.  
  106. void initGame() {
  107. gb.pickRandomSeed();
  108. misses = 0;
  109. score = 0;
  110. BoatPosition = 1;
  111. spawnDelay = 2;
  112. shark_anim = 0;
  113. moveTick = 30;
  114. }
  115.  
  116. void setup() {
  117. gb.begin();
  118. initGame();
  119. }
  120. void drawBackground() {
  121. //Draw gray background
  122. gb.display.setColor(GRAY, WHITE);
  123. gb.display.drawBitmap(0, 0, subBackgroundBitmap);
  124. gb.display.setColor(BLACK, WHITE);
  125. }
  126.  
  127. void anim_shark() {
  128.  
  129. if (shark_anim == 1) gb.display.drawBitmap(40 , 38, aileron);
  130. if (shark_anim == 2) gb.display.drawBitmap(22 , 38, aileron);
  131. if (shark_anim == 3) gb.display.drawBitmap(13 , 42, aileron,0,FLIPH);
  132. if (shark_anim == 4) gb.display.drawBitmap(29 , 42, aileron,0,FLIPH);
  133. if (shark_anim == 5) {
  134. gb.display.drawBitmap(48 , 40, requin_p1);
  135. gb.display.drawBitmap(56 , 40, requin_p2);
  136. // Traiter la fin de l’animation du requin
  137. shark_anim = 0;
  138. }
  139. }
  140.  
  141. void loop() {
  142.  
  143. while (1) {
  144. if (gb.update()) {
  145. gb.display.clear();
  146. drawBackground();
  147. if(gb.buttons.pressed(BTN_LEFT) || gb.buttons.pressed(BTN_A) ){
  148. if (BoatPosition > 1) BoatPosition--;
  149. }
  150. if(gb.buttons.pressed(BTN_RIGHT) || gb.buttons.pressed(BTN_B) ){
  151. if (BoatPosition < 3) BoatPosition++;
  152. }
  153. x = BoatPosition * 16 - 8;
  154. gb.display.drawBitmap(x , 30, barque_p1);
  155. gb.display.drawBitmap(x+8 , 30, barque_p2);
  156.  
  157.     anim_shark();
  158.    
  159.     if (moveTick > 0) {
  160.         moveTick --;
  161.     }
  162.     else {
  163.       // if ((shark_anim > 0) || ((shark_anim = 0) && (random(50) < 20))) {
  164.         shark_anim++;
  165.        // }
  166.        moveTick = 30;
  167.     }
  168.   }  
  169. }  
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement