├── .gitignore ├── .travis.yml ├── README.md ├── design ├── gameduino-2-0.123dx ├── gameduino-2-1.123dx ├── gameduino-2-printable.123dx ├── gameduino-sketch.123dx ├── gameduino.123dx ├── render.png └── skin │ ├── 5-way.psd │ ├── gameduino-blueprint.psd │ ├── gameduino-colored.psd │ ├── gameduino-mini-blueprint.psd │ ├── gameduino-mini-colored.psd │ └── logo-bw.psd ├── lib └── readme.txt ├── platformio.ini └── src ├── gameduino ├── GameConsole.cpp ├── GameConsole.h ├── components │ ├── Buttons.cpp │ ├── Buttons.h │ ├── Buzzer.cpp │ ├── Buzzer.h │ ├── Component.h │ ├── Joystick.cpp │ ├── Joystick.h │ └── Screen.h ├── images │ └── logo.h └── scenes │ ├── EngineeringModeScene.cpp │ ├── EngineeringModeScene.h │ ├── GameOverScene.cpp │ ├── GameOverScene.h │ ├── GameScene.cpp │ └── GameScene.h └── games └── mario ├── MainScene.cpp ├── MainScene.h ├── MarioGame.cpp └── images ├── background.h └── sprite.h /.gitignore: -------------------------------------------------------------------------------- 1 | .pioenvs 2 | .clang_complete 3 | .gcc-flags.json 4 | .piolibdeps 5 | movie -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Continuous Integration (CI) is the practice, in software 2 | # engineering, of merging all developer working copies with a shared mainline 3 | # several times a day < http://docs.platformio.org/en/stable/ci/index.html > 4 | # 5 | # Documentation: 6 | # 7 | # * Travis CI Embedded Builds with PlatformIO 8 | # < https://docs.travis-ci.com/user/integration/platformio/ > 9 | # 10 | # * PlatformIO integration with Travis CI 11 | # < http://docs.platformio.org/en/stable/ci/travis.html > 12 | # 13 | # * User Guide for `platformio ci` command 14 | # < http://docs.platformio.org/en/stable/userguide/cmd_ci.html > 15 | # 16 | # 17 | # Please choice one of the following templates (proposed below) and uncomment 18 | # it (remove "# " before each line) or use own configuration according to the 19 | # Travis CI documentation (see above). 20 | # 21 | 22 | 23 | # 24 | # Template #1: General project. Test it using existing `platformio.ini`. 25 | # 26 | 27 | # language: python 28 | # python: 29 | # - "2.7" 30 | # 31 | # sudo: false 32 | # cache: 33 | # directories: 34 | # - "~/.platformio" 35 | # 36 | # install: 37 | # - pip install -U platformio 38 | # 39 | # script: 40 | # - platformio run 41 | 42 | 43 | # 44 | # Template #2: The project is intended to by used as a library with examples 45 | # 46 | 47 | # language: python 48 | # python: 49 | # - "2.7" 50 | # 51 | # sudo: false 52 | # cache: 53 | # directories: 54 | # - "~/.platformio" 55 | # 56 | # env: 57 | # - PLATFORMIO_CI_SRC=path/to/test/file.c 58 | # - PLATFORMIO_CI_SRC=examples/file.ino 59 | # - PLATFORMIO_CI_SRC=path/to/test/directory 60 | # 61 | # install: 62 | # - pip install -U platformio 63 | # 64 | # script: 65 | # - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gameduino 2 | An Arduino/ESP8266 based game platform 3 | 4 | ## 3D Preview 5 | ![](https://github.com/MagicCube/gameduino/blob/master/design/render.png?raw=true) 6 | -------------------------------------------------------------------------------- /design/gameduino-2-0.123dx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/gameduino-2-0.123dx -------------------------------------------------------------------------------- /design/gameduino-2-1.123dx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/gameduino-2-1.123dx -------------------------------------------------------------------------------- /design/gameduino-2-printable.123dx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/gameduino-2-printable.123dx -------------------------------------------------------------------------------- /design/gameduino-sketch.123dx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/gameduino-sketch.123dx -------------------------------------------------------------------------------- /design/gameduino.123dx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/gameduino.123dx -------------------------------------------------------------------------------- /design/render.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/render.png -------------------------------------------------------------------------------- /design/skin/5-way.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/skin/5-way.psd -------------------------------------------------------------------------------- /design/skin/gameduino-blueprint.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/skin/gameduino-blueprint.psd -------------------------------------------------------------------------------- /design/skin/gameduino-colored.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/skin/gameduino-colored.psd -------------------------------------------------------------------------------- /design/skin/gameduino-mini-blueprint.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/skin/gameduino-mini-blueprint.psd -------------------------------------------------------------------------------- /design/skin/gameduino-mini-colored.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/skin/gameduino-mini-colored.psd -------------------------------------------------------------------------------- /design/skin/logo-bw.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MagicCube/gameduino/935e10bae630bb0f6d692b11f26f6375bd3dee19/design/skin/logo-bw.psd -------------------------------------------------------------------------------- /lib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for the project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link to executable file. 4 | 5 | The source code of each library should be placed in separate directory, like 6 | "lib/private_lib/[here are source files]". 7 | 8 | For example, see how can be organized `Foo` and `Bar` libraries: 9 | 10 | |--lib 11 | | |--Bar 12 | | | |--docs 13 | | | |--examples 14 | | | |--src 15 | | | |- Bar.c 16 | | | |- Bar.h 17 | | |--Foo 18 | | | |- Foo.c 19 | | | |- Foo.h 20 | | |- readme.txt --> THIS FILE 21 | |- platformio.ini 22 | |--src 23 | |- main.c 24 | 25 | Then in `src/main.c` you should use: 26 | 27 | #include 28 | #include 29 | 30 | // rest H/C/CPP code 31 | 32 | PlatformIO will find your libraries automatically, configure preprocessor's 33 | include paths and build them. 34 | 35 | More information about PlatformIO Library Dependency Finder 36 | - http://docs.platformio.org/en/stable/librarymanager/ldf.html 37 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter, extra scripting 4 | ; Upload options: custom port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; 7 | ; Please visit documentation for the other options and examples 8 | ; http://docs.platformio.org/en/stable/projectconf.html 9 | 10 | [env:micro] 11 | platform = atmelavr 12 | board = micro 13 | framework = arduino 14 | lib_deps = Adafruit GFX Library 15 | Adafruit SSD1306 16 | -------------------------------------------------------------------------------- /src/gameduino/GameConsole.cpp: -------------------------------------------------------------------------------- 1 | #include "GameConsole.h" 2 | 3 | #include "./images/logo.h" 4 | 5 | GameConsole::GameConsole(): display(4) 6 | { 7 | 8 | } 9 | 10 | void GameConsole::begin() 11 | { 12 | display.begin(SSD1306_SWITCHCAPVCC, 0x3c); 13 | display.setTextColor(WHITE); 14 | 15 | display.fillScreen(WHITE); 16 | display.drawBitmap((128 - 80)/ 2, (64 - 56) / 2, GAMEDUINO_LOGO, 80, 56, BLACK); 17 | 18 | buzzer.begin(); 19 | buzzer.beep(); 20 | 21 | delay(800); 22 | 23 | display.clearDisplay(); 24 | } 25 | 26 | void GameConsole::update() 27 | { 28 | this->joystick.update(); 29 | this->buttons.update(); 30 | } 31 | 32 | void GameConsole::render() 33 | { 34 | this->display.display(); 35 | } 36 | -------------------------------------------------------------------------------- /src/gameduino/GameConsole.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_CONSOLE_H 2 | #define GAME_CONSOLE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "./components/Buzzer.h" 10 | #include "./components/Buttons.h" 11 | #include "./components/Joystick.h" 12 | 13 | class GameConsole 14 | { 15 | 16 | public: 17 | Adafruit_SSD1306 display; 18 | Buzzer buzzer; 19 | Buttons buttons; 20 | Joystick joystick; 21 | 22 | GameConsole(); 23 | void begin(); 24 | void update(); 25 | void render(); 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/gameduino/components/Buttons.cpp: -------------------------------------------------------------------------------- 1 | #include "Buttons.h" 2 | 3 | #define LEFT_BUTTON_PIN 9 4 | #define DOWN_BUTTON_PIN 10 5 | #define UP_BUTTON_PIN 11 6 | #define RIGHT_BUTTON_PIN 12 7 | 8 | void Buttons::begin() 9 | { 10 | for (int i = LEFT_BUTTON_PIN; i <= RIGHT_BUTTON_PIN; i++) 11 | { 12 | pinMode(i, INPUT); 13 | } 14 | } 15 | 16 | void Buttons::update() 17 | { 18 | for (int i = LEFT_BUTTON_PIN; i <= RIGHT_BUTTON_PIN; i++) 19 | { 20 | if (digitalRead(i) == LOW) 21 | { 22 | switch (i) 23 | { 24 | case LEFT_BUTTON_PIN: 25 | state = LEFT_BUTTON; 26 | break; 27 | case RIGHT_BUTTON_PIN: 28 | state = RIGHT_BUTTON; 29 | break; 30 | case UP_BUTTON_PIN: 31 | state = UP_BUTTON; 32 | break; 33 | case DOWN_BUTTON_PIN: 34 | state = DOWN_BUTTON; 35 | break; 36 | } 37 | return; 38 | } 39 | } 40 | state = 0; 41 | } 42 | -------------------------------------------------------------------------------- /src/gameduino/components/Buttons.h: -------------------------------------------------------------------------------- 1 | #ifndef BUTTONS_H 2 | #define BUTTONS_H 3 | 4 | #include "Component.h" 5 | 6 | #define LEFT_BUTTON 1 7 | #define DOWN_BUTTON 2 8 | #define UP_BUTTON 4 9 | #define RIGHT_BUTTON 8 10 | 11 | class Buttons : public Component 12 | { 13 | public: 14 | int state; 15 | 16 | void begin(); 17 | void update(); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/gameduino/components/Buzzer.cpp: -------------------------------------------------------------------------------- 1 | #include "Buzzer.h" 2 | 3 | void Buzzer::begin() 4 | { 5 | pinMode(BUZZER_PIN, OUTPUT); 6 | } 7 | 8 | void Buzzer::beep() 9 | { 10 | digitalWrite(BUZZER_PIN, HIGH); 11 | delay(50); 12 | digitalWrite(BUZZER_PIN, LOW); 13 | delay(50); 14 | } 15 | -------------------------------------------------------------------------------- /src/gameduino/components/Buzzer.h: -------------------------------------------------------------------------------- 1 | #ifndef BUZZER_H 2 | #define BUZZER_H 3 | 4 | #include "Component.h" 5 | 6 | #define BUZZER_PIN 5 7 | 8 | class Buzzer : public Component 9 | { 10 | public: 11 | void begin(); 12 | void beep(); 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/gameduino/components/Component.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPONENT_H 2 | #define COMPONENT_H 3 | 4 | #include 5 | 6 | class Component 7 | { 8 | public: 9 | virtual void begin(); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/gameduino/components/Joystick.cpp: -------------------------------------------------------------------------------- 1 | #include "Joystick.h" 2 | 3 | void Joystick::begin() 4 | { 5 | 6 | } 7 | 8 | void Joystick::update() 9 | { 10 | int rawX = analogRead(JOYSTICK_X_PIN); 11 | int rawY = analogRead(JOYSTICK_Y_PIN); 12 | if (rawX > 490 && rawX < 520) 13 | { 14 | rawX = 512; 15 | } 16 | else if (rawX > 1000) 17 | { 18 | rawX = 1023; 19 | } 20 | if (rawY > 490 && rawY < 520) 21 | { 22 | rawY = 512; 23 | } 24 | else if (rawY > 1000) 25 | { 26 | rawY = 1023; 27 | } 28 | 29 | x = map(rawX, 0, 1023, -100, 100); 30 | y = map(rawY, 0, 1023, 100, -100); 31 | } 32 | 33 | int Joystick::leftStroke() 34 | { 35 | return x; 36 | } 37 | 38 | int Joystick::rightStroke() 39 | { 40 | return abs(x); 41 | } 42 | 43 | int Joystick::upStroke() 44 | { 45 | return y; 46 | } 47 | 48 | int Joystick::downStroke() 49 | { 50 | return abs(y); 51 | } 52 | -------------------------------------------------------------------------------- /src/gameduino/components/Joystick.h: -------------------------------------------------------------------------------- 1 | #ifndef JOYSTICK_H 2 | #define JOYSTICK_H 3 | 4 | #include "Component.h" 5 | 6 | #define JOYSTICK_X_PIN 0 7 | #define JOYSTICK_Y_PIN 1 8 | #define JOYSTICK_K_PIN 2 9 | 10 | class Joystick : public Component 11 | { 12 | public: 13 | int x; 14 | int y; 15 | 16 | void begin(); 17 | void update(); 18 | 19 | int leftStroke(); 20 | int rightStroke(); 21 | int upStroke(); 22 | int downStroke(); 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/gameduino/components/Screen.h: -------------------------------------------------------------------------------- 1 | #ifndef SCREEN_H 2 | #define SCREEN_H 3 | 4 | 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/gameduino/images/logo.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGO_H 2 | #define LOGO_H 3 | 4 | #include 5 | 6 | //------------------------------------------------------------------------------ 7 | // File generated by LCD Assistant 8 | // http://en.radzio.dxp.pl/bitmap_converter/ 9 | //------------------------------------------------------------------------------ 10 | 11 | static const unsigned char PROGMEM GAMEDUINO_LOGO [] = { 12 | 0x00, 0x01, 0xFF, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 13 | 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0xFF, 14 | 0xFF, 0xFE, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0xFF, 0xFF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 0x00, 0x00, 0x00, 0x00, 37 | 0x3C, 0x1C, 0x3C, 0x39, 0xFC, 0xFC, 0x61, 0xB3, 0x0C, 0x3C, 0x7E, 0x3C, 0x3C, 0x39, 0xFC, 0xFE, 38 | 0x61, 0xB3, 0x8C, 0x7E, 0xC3, 0x3C, 0x3C, 0x39, 0x80, 0xC3, 0x61, 0xB3, 0x8C, 0xC3, 0xC3, 0x3E, 39 | 0x3C, 0x79, 0x80, 0xC3, 0x61, 0xB3, 0x8C, 0xC3, 0xC3, 0x3E, 0x3C, 0x79, 0x80, 0xC3, 0x61, 0xB3, 40 | 0xCC, 0xC3, 0xC0, 0x36, 0x3E, 0x79, 0x80, 0xC3, 0x61, 0xB3, 0xCC, 0xC3, 0xC0, 0x36, 0x3E, 0x79, 41 | 0x80, 0xC3, 0x61, 0xB3, 0xCC, 0xC3, 0xCF, 0x76, 0x3E, 0x79, 0xF8, 0xC3, 0x61, 0xB3, 0x6C, 0xC3, 42 | 0xCF, 0x76, 0x36, 0xD9, 0xF8, 0xC3, 0x61, 0xB3, 0x6C, 0xC3, 0xC3, 0x77, 0x36, 0xD9, 0x80, 0xC3, 43 | 0x61, 0xB3, 0x6C, 0xC3, 0xC3, 0x7F, 0x37, 0xD9, 0x80, 0xC3, 0x61, 0xB3, 0x3C, 0xC3, 0xC3, 0x7F, 44 | 0x37, 0xD9, 0x80, 0xC3, 0x61, 0xB3, 0x3C, 0xC3, 0xC3, 0x63, 0x33, 0xD9, 0x80, 0xC3, 0x61, 0xB3, 45 | 0x3C, 0xC3, 0xC7, 0xC3, 0x33, 0x99, 0x80, 0xC7, 0x61, 0xB3, 0x1C, 0xC3, 0x7E, 0xC3, 0x33, 0x99, 46 | 0xFC, 0xFE, 0x3F, 0x33, 0x1C, 0x7E, 0x3C, 0xC1, 0xB3, 0x99, 0xFC, 0xFC, 0x1E, 0x33, 0x0C, 0x3C 47 | }; 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/gameduino/scenes/EngineeringModeScene.cpp: -------------------------------------------------------------------------------- 1 | #include "EngineeringModeScene.h" 2 | 3 | void EngineeringModeScene::update(GameConsole console) 4 | { 5 | console.display.clearDisplay(); 6 | console.display.setCursor(0, 0); 7 | console.display.println("Engineering Mode"); 8 | 9 | console.display.print("X: "); 10 | console.display.println(console.joystick.x); 11 | console.display.print("Y: "); 12 | console.display.println(console.joystick.y); 13 | 14 | console.display.print("Button: "); 15 | switch(console.buttons.state) 16 | { 17 | case LEFT_BUTTON: 18 | console.display.print("Left "); 19 | break; 20 | case RIGHT_BUTTON: 21 | console.display.print("Right "); 22 | break; 23 | case UP_BUTTON: 24 | console.display.print("Up "); 25 | break; 26 | case DOWN_BUTTON: 27 | console.display.print("Down "); 28 | break; 29 | } 30 | console.display.println(console.buttons.state); 31 | } 32 | -------------------------------------------------------------------------------- /src/gameduino/scenes/EngineeringModeScene.h: -------------------------------------------------------------------------------- 1 | #ifndef ENGINEERING_MODE_SCENE_H 2 | #define ENGINEERING_MODE_SCENE_H 3 | 4 | #include "../GameConsole.h" 5 | #include "GameScene.h" 6 | 7 | class EngineeringModeScene : public GameScene 8 | { 9 | public: 10 | void update(GameConsole console); 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/gameduino/scenes/GameOverScene.cpp: -------------------------------------------------------------------------------- 1 | #include "GameOverScene.h" 2 | 3 | void GameOverScene::update(GameConsole console) 4 | { 5 | console.display.clearDisplay(); 6 | console.display.setCursor(0, 0); 7 | console.display.setTextSize(2); 8 | console.display.println(" GAME"); 9 | console.display.println(" OVER"); 10 | } 11 | -------------------------------------------------------------------------------- /src/gameduino/scenes/GameOverScene.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_OVER_SCENE_H 2 | #define GAME_OVER_SCENE_H 3 | 4 | #include "../GameConsole.h" 5 | #include "GameScene.h" 6 | 7 | class GameOverScene : public GameScene 8 | { 9 | public: 10 | void update(GameConsole console); 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/gameduino/scenes/GameScene.cpp: -------------------------------------------------------------------------------- 1 | #include "GameScene.h" 2 | 3 | void update(GameConsole console) 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/gameduino/scenes/GameScene.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_SCENE_H 2 | #define GAME_SCENE_H 3 | 4 | #include "../GameConsole.h" 5 | 6 | class GameScene 7 | { 8 | public: 9 | void update(GameConsole console); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/games/mario/MainScene.cpp: -------------------------------------------------------------------------------- 1 | #include "MainScene.h" 2 | 3 | #include "images/background.h" 4 | #include "images/sprite.h" 5 | 6 | void MainScene::update(GameConsole console) 7 | { 8 | console.display.drawBitmap(0, 0, BACKGROUND, 128, 64, WHITE); 9 | console.display.drawBitmap(50, 64 - 8 - 24, SPRITE_FORWARD_1, 24, 24, WHITE); 10 | } 11 | -------------------------------------------------------------------------------- /src/games/mario/MainScene.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_SCENE_H 2 | #define MAIN_SCENE_H 3 | 4 | #include "../../gameduino/GameConsole.h" 5 | 6 | #include "../../gameduino/scenes/GameScene.h" 7 | 8 | class MainScene : public GameScene 9 | { 10 | public: 11 | void update(GameConsole console); 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/games/mario/MarioGame.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../../gameduino/GameConsole.h" 4 | 5 | #include "../../gameduino/scenes/GameScene.h" 6 | #include "../../gameduino/scenes/GameOverScene.h" 7 | #include "../../gameduino/scenes/EngineeringModeScene.h" 8 | #include "MainScene.h" 9 | 10 | GameConsole console; 11 | EngineeringModeScene mainScene; 12 | 13 | void setup() 14 | { 15 | console.begin(); 16 | } 17 | 18 | void loop() 19 | { 20 | console.update(); 21 | mainScene.update(console); 22 | console.render(); 23 | } 24 | -------------------------------------------------------------------------------- /src/games/mario/images/background.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKGROUND_IMG_H 2 | #define BACKGROUND_IMG_H 3 | 4 | #include 5 | 6 | static const unsigned char PROGMEM BACKGROUND [] = { 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x70, 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x32, 0x00, 0x00, 0x00, 0x20, 0x24, 0x08, 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x22, 0x00, 0x00, 0x00, 0x20, 0x04, 0x08, 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x20, 0x18, 0x30, 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x22, 0x00, 0x00, 0x00, 0x20, 0x18, 0x08, 14 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x20, 0x24, 0x08, 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x24, 0x70, 16 | 0x00, 0x07, 0xE0, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x07, 0xE0, 0x7E, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x38, 0x19, 0xC1, 0x80, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | 0x00, 0x19, 0x1D, 0x81, 0x80, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x00, 0x61, 0xFF, 0xE0, 0x60, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x61, 0xFF, 0xE2, 0x60, 0x60, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x61, 0x9E, 0x18, 0x60, 0xF0, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x61, 0x9E, 0x18, 0x61, 0xF8, 0x02, 0x07, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x06, 0x06, 0x46, 0x03, 0xF8, 0x04, 0x04, 0xA6, 0x53, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x00, 0x06, 0x06, 0x06, 0x07, 0xBC, 0x08, 0x07, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x06, 0x06, 0x06, 0x0F, 0x1E, 0x08, 0x05, 0x16, 0x8B, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x0E, 0x06, 0x06, 0x1E, 0x0F, 0x10, 0x05, 0x16, 0x8B, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x06, 0x00, 0x1C, 0x07, 0xA0, 0x07, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x06, 0x00, 0x3C, 0x03, 0xC0, 0x04, 0xA6, 0x53, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x06, 0x00, 0x78, 0x03, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x06, 0x00, 0xF0, 0x01, 0xE0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x06, 0x01, 0xE0, 0x00, 0xF0, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x06, 0x03, 0xC0, 0x00, 0x78, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0x06, 0x07, 0x80, 0x00, 0x3C, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 35 | 0x00, 0x00, 0x06, 0x07, 0x80, 0x00, 0x1E, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 36 | 0x00, 0x00, 0x06, 0x0F, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x06, 0x1E, 0x00, 0x00, 0x07, 0x80, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x06, 0x3C, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x06, 0x78, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x06, 0x70, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x06, 0x70, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 44 | 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 46 | 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x02, 0x00, 0x00, 0x7F, 0xFF, 0x00, 47 | 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x01, 0x00, 0x01, 0x80, 0x00, 0xC0, 48 | 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x80, 0x02, 0x7F, 0xFF, 0x40, 49 | 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 50 | 0x00, 0x00, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x20, 0x03, 0xFF, 0xFF, 0xC0, 51 | 0x00, 0x01, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x10, 0x00, 0x80, 0x01, 0x00, 52 | 0x00, 0x03, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x08, 0x00, 0x80, 0x01, 0x00, 53 | 0x00, 0x07, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x04, 0x00, 0x80, 0x01, 0x00, 54 | 0x00, 0x07, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x02, 0x00, 0x80, 0x01, 0x00, 55 | 0x00, 0x0F, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x80, 0x01, 0x00, 56 | 0x00, 0x1E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 57 | 0x00, 0x3C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x40, 0x80, 0x01, 0x00, 58 | 0x00, 0x78, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x40, 0x80, 0x01, 0x00, 59 | 0x00, 0xF0, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x30, 0x80, 0x01, 0x00, 60 | 0x00, 0xF0, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x18, 0x80, 0x01, 0x00, 61 | 0x01, 0xE0, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x0C, 0x80, 0x01, 0x00, 62 | 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x06, 0x80, 0x01, 0x00, 63 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 64 | 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 65 | 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 66 | 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 67 | 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 68 | 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 69 | 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 70 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF 71 | }; 72 | 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /src/games/mario/images/sprite.h: -------------------------------------------------------------------------------- 1 | #ifndef SPRITE_IMG_H 2 | #define SPRITE_IMG_H 3 | 4 | #include 5 | 6 | static const unsigned char PROGMEM SPRITE_FORWARD_1 [] = { 7 | 0x00, 0xFC, 0x00, 0x00, 0xFC, 0x00, 0x03, 0xFF, 0xF0, 0x03, 0xFF, 0xF0, 0x0F, 0xFB, 0x80, 0x0F, 8 | 0xC7, 0x40, 0x3F, 0xE1, 0x30, 0x3D, 0xE0, 0x50, 0x3C, 0xC3, 0xC0, 0x3F, 0x07, 0xF0, 0x01, 0x05, 9 | 0x00, 0x01, 0x0A, 0x8C, 0x0F, 0xBF, 0x0C, 0x0F, 0xFF, 0x3C, 0x1F, 0xFD, 0xFC, 0x1F, 0xFF, 0xF0, 10 | 0x0B, 0x1C, 0xF0, 0x07, 0x28, 0xF0, 0x03, 0xFF, 0xD0, 0x06, 0xD7, 0x70, 0x03, 0xF1, 0xE0, 0x01, 11 | 0xE3, 0xC0, 0x07, 0xE3, 0xF0, 0x07, 0xF3, 0xF0, 12 | }; 13 | 14 | static const unsigned char PROGMEM SPRITE_FORWARD_2 [] = { 15 | 0x03, 0xF0, 0x03, 0xF0, 0x0F, 0xFF, 0x0F, 0xFF, 0x3F, 0xEE, 0x3F, 0x1D, 0xFF, 0x84, 0xF7, 0x81, 16 | 0xF3, 0x0F, 0xFC, 0x1F, 0x04, 0x14, 0x04, 0x2A, 0x3E, 0xFC, 0x3F, 0xFC, 0x7F, 0xF7, 0x7F, 0xFF, 17 | 0x2C, 0x73, 0x5C, 0xA3, 0x4F, 0xFF, 0x7B, 0x5D, 0x0F, 0xC7, 0x03, 0xC7, 0x03, 0xC7, 0x03, 0xE7, 18 | 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | }; 20 | 21 | static const unsigned char PROGMEM SPRITE_BACKWARD_1 [] = { 22 | 0x00, 0xFC, 0x00, 0xFC, 0x3F, 0xFF, 0x3F, 0xFF, 0x07, 0x7F, 0x0B, 0x8F, 0x32, 0x1F, 0x28, 0x1E, 23 | 0x0F, 0x0C, 0x3F, 0x83, 0x02, 0x82, 0xC5, 0x42, 0xC3, 0xF7, 0xF3, 0xFF, 0xFE, 0xFF, 0x3F, 0xFF, 24 | 0x3C, 0xE3, 0x3C, 0x53, 0x2F, 0xFF, 0x3B, 0xAD, 0x1E, 0x3F, 0x0F, 0x1E, 0x3F, 0x1F, 0x3F, 0x3F, 25 | 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | }; 27 | 28 | static const unsigned char PROGMEM SPRITE_BACKWARD_2 [] = { 29 | 0x00, 0xFC, 0x00, 0xFC, 0x3F, 0xFF, 0x3F, 0xFF, 0x07, 0x7F, 0x0B, 0x8F, 0x32, 0x1F, 0x28, 0x1E, 30 | 0x0F, 0x0C, 0x3F, 0x83, 0x02, 0x82, 0x05, 0x42, 0x03, 0xF7, 0x03, 0xFF, 0x7E, 0xFF, 0x3F, 0xFF, 31 | 0x7C, 0xE3, 0xBC, 0x53, 0xAF, 0xFF, 0x9B, 0xAD, 0x1E, 0x3F, 0x1E, 0x3C, 0x7E, 0x3C, 0x7E, 0x7C, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | }; 34 | #endif 35 | --------------------------------------------------------------------------------