#100 ArdWinVaders
An Arduino & OLED version of a classic game.
Here’s a quick video of the game in action:
Or see this earlier video before the screen optimisations or sound. There’s a huge performance difference!
Notes
Since playing around with driving an OLED with an Arduino (see the SSD1306BareBack project for example), it doesn’t take long for the mind to wander into gaming territory…
So here’s the first version of a retro classic: Space Invaders in full 128x64 mono resolution running on an Arduino Pro Mini at 8MHz!
For details and discussion of the hardware setup, see the SSD1306BareBack project. This build is mainly about the software.
The software is organised into a number of classes. You can see the code for more details, but here is the overview:
- ArdWinVaders.ino - main program, also handles all the controls input (fire, movement)
- game_board.h/cpp - implements the main game controller class, responsible for orchestrating actions and sequencing gameplay
- buffered_display.h/cpp - implements a logical display interface that GameBoard talks to. It maintains the screen buffer and handles movement, collision detection and so on.
- oled_driver.h/cpp - implements the OLED-specific display driver. It goes direct to the hardware via SPI.
- sound_system.h/cpp - music and sound effects support.
Game performance/screen refresh is pretty awesome even with the processor at 8Mhz. The big improvement came from switching to direct port manipulation for SPI rather than using the standard library methods (digitalWrite, shiftOut).
TODO
- put it in a hand-held form-factor
Construction
Credits and References
- SSD1306 datasheet
- SSD1306BareBack - a sketch the exlores and explains OLED driving basics
- Arduino Port Registers - all the info needed for direct port manipulation
- ..as mentioned on my blog