Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAX_LEVELS 2
- #include <Arduboy2.h>
- #include <bitmaps.h>
- Arduboy2 arduboy;
- int level = 1;
- byte animToggle;
- byte platforms[] = {
- 2,3,3,9,2,2,11,5,4,
- 4,2,2,2,5,4,9,3,3
- };
- struct objects
- {
- byte type;
- byte x;
- byte y;
- float xRate;
- float yRate;
- boolean direction;
- byte state;
- } ;
- struct objects gameObjects[2][10];
- struct gameObjects[0][0] = { 1,24,48,0,0,1,0};
- void setup()
- {
- Serial.begin(115200);
- arduboy.boot(); // raw hardware
- arduboy.blank(); // blank the display
- arduboy.flashlight(); // light the RGB LED and screen if UP button is being held.
- arduboy.systemButtons();
- //arduboy.bootLogo();
- arduboy.audio.begin();
- arduboy.clear();
- randomSeed(analogRead(0));
- arduboy.setFrameRate(60);
- }
- void drawThings()
- {
- for (int index=0; index<10; index++)
- {
- byte type = gameObjects[level-1][index].type;
- byte x = gameObjects[level-1][index].x;
- byte y = gameObjects[level-1][index].y;
- boolean direction = gameObjects[level-1][index].direction;
- byte state = gameObjects[level-1][index].state;
- if (type==1) drawJetMan(x, y, direction, state);
- }
- }
- void drawJetMan(byte x, byte y, boolean direction, byte state)
- {
- if (direction)
- {
- if (state==0)
- {
- arduboy.drawBitmap(x,y, JETMANRIGHTHEAD, 8, 8);
- arduboy.drawBitmap(x, y, JETMANRIGHT1, 8, 8);
- }
- else
- {
- arduboy.drawBitmap(x, y, JETMANLEFTHEAD, 8, 8);
- arduboy.drawBitmap(x, y, JETMANLEFT1, 8, 8);
- }
- }
- }
- void drawPlatforms()
- {
- for (byte index = level*9; index<(level*9)+9; index=index+3)
- {
- for (byte row = 0; row < platforms[index+2]; row++)
- {
- arduboy.drawBitmap((platforms[index]*8)+(row*8), platforms[index+1]*8, PLATFORM, 8, 8);
- }
- }
- }
- void loop() {
- if (!arduboy.nextFrame()) return; // Keep frame rate at 60fps
- arduboy.drawFastHLine(0, 63, 128); // ground
- drawPlatforms();
- drawThings();
- Serial.write(arduboy.getBuffer(), 128 * 64 / 8);
- arduboy.display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement