Advertisement
Guest User

crazy cpp

a guest
Jan 19th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.05 KB | None | 0 0
  1. #include <Arduboy2.h>
  2. const unsigned char PlayFieldTiles[] PROGMEM  = {0xf0, 0x0c, 0x02, 0xe2, 0x11, 0x09, 0x09, 0x09,
  3.                                                  0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
  4.                                                  0x09, 0x09, 0x09, 0x11, 0xe1, 0x01, 0x01, 0x01,
  5.                                                  0x01, 0x01, 0x01, 0xe1, 0x11, 0x09, 0x09, 0x09,
  6.                                                  0x09, 0x09, 0x09, 0x11, 0xe2, 0x02, 0x0c, 0xf0,
  7.                                                  0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
  8.                                                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9.                                                  0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
  10.                                                  0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
  11.                                                  0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
  12.                                                  0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x10, 0x10,
  13.                                                  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
  14.                                                  0x10, 0x10, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00,
  15.                                                  0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x08, 0x08,
  16.                                                  0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
  17.                                                  0x08, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00,
  18.                                                  0x08, 0x08, 0x08, 0x10, 0xe0, 0x00, 0x00, 0x00,
  19.                                                  0x00, 0x00, 0x00, 0xe0, 0x10, 0x08, 0x08, 0x08,
  20.                                                  0x0f, 0x30, 0x40, 0x47, 0x88, 0x90, 0x90, 0x90,
  21.                                                  0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
  22.                                                  0x00, 0x00, 0x00, 0x07, 0x08, 0x10, 0x10, 0x10,
  23.                                                  0x10, 0x10, 0x10, 0x08, 0x07, 0x00, 0x00, 0x00,
  24.                                                  0x90, 0x90, 0x90, 0x88, 0x47, 0x40, 0x30, 0x0f,
  25.                                                  0x00, 0x00, 0x00, 0x00, 0xf0, 0x10, 0x10, 0x90,
  26.                                                  0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xf0,
  27.                                                  0x40, 0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x20,
  28.                                                  0xf0, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
  29.                                                  0x90, 0x10, 0x10, 0xf0, 0x00, 0x00, 0x00, 0x00,
  30.                                                  0x00, 0x00, 0x00, 0x00, 0x0f, 0x08, 0x08, 0x09,
  31.                                                  0x09, 0x08, 0x08, 0x0f, 0x00, 0x00, 0x00, 0x00,
  32.                                                  0xff, 0x00, 0x00, 0x07, 0x08, 0x10, 0x10, 0x10,
  33.                                                  0x10, 0x10, 0x10, 0x08, 0x07, 0x00, 0x00, 0xff,
  34.                                                  0xff, 0x00, 0x00, 0xe0, 0x10, 0x08, 0x08, 0x08,
  35.                                                  0x08, 0x08, 0x08, 0x10, 0xe0, 0x00, 0x00, 0xff,
  36.                                                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  37.                                                 };
  38. const unsigned char PlayFieldMap[] PROGMEM  = {0,1,1,1,1,1,1,1,1,1,1,1,1,2,3,1,1,1,1,1,1,1,1,1,1,1,1,4,5,6,6,6,6,6,6,6,6,6,6,6,6,7,8,6,6,6,6,6,6,6,6,6,6,6,6,9,5,6,10,11,11,12,6,10,11,11,11,12,6,7,8,6,10,11,11,11,12,6,10,11,11,12,6,9,5,6,7,6,6,8,6,7,6,6,6,8,6,7,8,6,7,6,6,6,8,6,7,6,6,8,6,9,5,6,13,14,14,15,6,13,14,14,14,15,6,13,15,6,13,14,14,14,15,6,13,14,14,15,6,9,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,9,5,6,10,11,11,12,6,10,12,6,10,11,11,11,11,11,11,12,6,10,12,6,10,11,11,12,6,9,5,6,13,14,14,15,6,7,8,6,13,14,14,16,17,14,14,15,6,7,8,6,13,14,14,15,6,9,5,6,6,6,6,6,6,7,8,6,6,6,6,7,8,6,6,6,6,7,8,6,6,6,6,6,6,9,18,19,19,19,19,12,6,7,20,11,11,12,6,7,8,6,10,11,11,21,8,6,10,19,19,19,19,22,6,6,6,6,6,5,6,7,17,14,14,15,6,13,15,6,13,14,14,16,8,6,9,6,6,6,6,6,6,6,6,6,6,5,6,7,8,6,6,6,6,6,6,6,6,6,6,7,8,6,9,6,6,6,6,6,6,6,6,6,6,5,6,7,8,6,23,19,24,25,25,26,19,27,6,7,8,6,9,6,6,6,6,6,1,1,1,1,1,15,6,13,15,6,9,6,6,6,6,6,6,5,6,13,15,6,13,1,1,1,1,1,6,6,6,6,6,6,6,6,6,6,9,6,6,6,6,6,6,5,6,6,6,6,6,6,6,6,6,6,19,19,19,19,19,12,6,10,12,6,9,6,6,6,6,6,6,5,6,10,12,6,10,19,19,19,19,19,6,6,6,6,6,5,6,7,8,6,28,1,1,1,1,1,1,29,6,7,8,6,9,6,6,6,6,6,6,6,6,6,6,5,6,7,8,6,6,6,6,6,6,6,6,6,6,7,8,6,9,6,6,6,6,6,6,6,6,6,6,5,6,7,8,6,10,11,11,11,11,11,11,12,6,7,8,6,9,6,6,6,6,6,0,1,1,1,1,15,6,13,15,6,13,14,14,16,17,14,14,15,6,13,15,6,13,1,1,1,1,4,5,6,6,6,6,6,6,6,6,6,6,6,6,7,8,6,6,6,6,6,6,6,6,6,6,6,6,9,5,6,10,11,11,12,6,10,11,11,11,12,6,7,8,6,10,11,11,11,12,6,10,11,11,12,6,9,5,6,13,14,16,8,6,13,14,14,14,15,6,13,15,6,13,14,14,14,15,6,7,17,14,15,6,9,5,6,6,6,7,8,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,8,6,6,6,9,30,11,12,6,7,8,6,10,12,6,10,11,11,11,11,11,11,12,6,10,12,6,7,8,6,10,11,31,32,14,15,6,13,15,6,7,8,6,13,14,14,16,17,14,14,15,6,7,8,6,13,15,6,13,14,33,5,6,6,6,6,6,6,7,8,6,6,6,6,7,8,6,6,6,6,7,8,6,6,6,6,6,6,9,5,6,10,11,11,11,11,21,20,11,11,12,6,7,8,6,10,11,11,21,20,11,11,11,11,12,6,9,5,6,13,14,14,14,14,14,14,14,14,15,6,13,15,6,13,14,14,14,14,14,14,14,14,15,6,9,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,9,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,22};
  39.  
  40. Arduboy2 arduboy;
  41.  
  42.  
  43. void setup() {
  44.   arduboy.boot(); // Changing this to begin() will draw the first tile three times
  45.   arduboy.setFrameRate(1);
  46. }
  47.  
  48. void loop() {
  49.   if (!(arduboy.nextFrame())) {
  50.     return;
  51.   }
  52.   arduboy.clear();
  53.   updateTiles();
  54.   arduboy.display();
  55. }
  56.  
  57. void updateTiles() {
  58.   unsigned int i = 0;
  59.   for (int y = 0 ; y < 1 ; y++ ) {
  60.     for (int x = 0 ; x < 3 ; x++ ) { // increasing 3 will only draw the first tile
  61.       unsigned char idx = PlayFieldMap[i];
  62.       arduboy.drawBitmap(x * 8, y * 8, PlayFieldTiles + (idx << 3), 8, 8, WHITE);
  63.       i++;
  64.     }
  65.   }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement