Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Backlight.h>
- #include <Battery.h>
- #include <Buttons.h>
- #include <Display.h>
- #include <Gamebuino.h>
- #include <Sound.h>
- #include <SPI.h>
- Gamebuino gb;
- const PROGMEM byte Empty[] = //ID: 0
- {
- 8,8,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- };
- const PROGMEM byte Brick[] = //ID: 1
- {
- 8,8,
- B11111111,
- B00100001,
- B11111111,
- B10001000,
- B11111111,
- B00100001,
- B11111111,
- B10001000,
- };
- const PROGMEM byte SharpBrick[]= //ID: 2
- {
- 8,8,
- B11111111,
- B11000011,
- B10100101,
- B10011001,
- B10011001,
- B10100101,
- B11000011,
- B11111111,
- };
- const PROGMEM byte TowerBrick[]= //ID: 3
- {
- 8,8,
- B10101101,
- B10110101,
- B10101101,
- B10110101,
- B10101101,
- B10110101,
- B10101101,
- B10110101,
- };
- const PROGMEM byte Piston[]= //ID: 4
- {
- 8,8,
- B00000000,
- B01111110,
- B00100100,
- B00100100,
- B01000010,
- B00011000,
- B01111110,
- B00000000,
- };
- const PROGMEM byte Holder[]= //ID: 5
- {
- 8,8,
- B11111111,
- B10100101,
- B11111111,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- };
- const PROGMEM byte Teleporter1[]= //ID: 6
- {
- 8,8,
- B11111111,
- B10101011,
- B11010110,
- B10101100,
- B10101100,
- B11010110,
- B10101011,
- B11111111,
- };
- const PROGMEM byte Teleporter0[]= //ID: 7
- {
- 8,8,
- B11111111,
- B11010101,
- B01101011,
- B00110101,
- B00110101,
- B01101011,
- B11010101,
- B11111111,
- };
- const PROGMEM byte Wall[]= //ID: 8
- {
- 8,8,
- B11110000,
- B10010000,
- B10010000,
- B10010000,
- B10010000,
- B10010000,
- B10010000,
- B11110000,
- };
- const PROGMEM byte Ennemie[]= //ID: 8
- {
- 8,8,
- B11111111,
- B10000001,
- B10010011,
- B10010011,
- B10000001,
- B10000001,
- B10000001,
- B11111111,
- };
- const byte Map[] PROGMEM = {13,9,
- 8,8,
- 0,0,0,0,0,0,0,0,0,0,0,0,2,
- 2,1,2,5,5,8,0,0,0,0,0,0,7,
- 3,0,0,0,0,8,0,0,0,0,0,0,2,
- 3,0,0,0,0,0,4,5,2,0,0,0,3,
- 2,0,2,0,0,0,0,0,0,0,0,0,3,
- 3,0,3,0,0,0,0,0,0,0,0,0,3,
- 3,0,3,0,0,0,2,5,5,0,5,5,2,
- 3,0,3,0,9,0,3,0,9,0,0,0,7,
- 2,0,2,1,1,1,2,1,1,1,1,1,2,
- };
- const byte* sprites[10] = {
- Empty,
- Brick,
- SharpBrick,
- TowerBrick,
- Piston,
- Holder,
- Teleporter0,
- Teleporter1,
- Wall,
- Ennemie
- };
- byte getTile(byte x, byte y){
- /*if(x & 1)//odd
- return pgm_read_byte(Map + y*(13) + x/2) & B00001111;
- else //even
- return (pgm_read_byte(Map + y*(9) + x/2) >> 4);*/
- return pgm_read_byte(Map + (x+y*13));
- }
- int CPosX = 0;
- int CPosY = 0;
- void setup() {
- // put your setup code here, to run once:
- gb.begin();
- gb.titleScreen(F("BIGBLACKBOX Testing"));
- }
- void loop() {
- // put your main code here, to run repeatedly:
- if(gb.update()) {
- if(gb.buttons.pressed(BTN_UP))
- CPosY++;
- if(gb.buttons.pressed(BTN_DOWN))
- CPosY--;
- if(gb.buttons.pressed(BTN_RIGHT))
- CPosX--;
- if(gb.buttons.pressed(BTN_LEFT))
- CPosX++;
- for(byte x = 0; x < 13; x++) {
- for(byte y = 0; y < 9; y++) {
- byte Id;
- Id = getTile(x,y);
- gb.display.drawBitmap(CPosX + x*8, CPosY + y*8, sprites[Id]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement