OLED Pong
This game is from the old Ludum Dare platform. You can try viewing the original page on Web Archive
(may not load correctly).
(may not load correctly).
Another game for the Arduino! This one uses the widely-available SSD1306 OLED display, which gives us 128x64 pixels in a nice blue colour (also avalable with white). I used a raw SSD1306 module, so I needed a CD4050 level-shifter between Arduino (5V) and OLED (3.3V). Other OLED modules have this built-in.
I connected an analog joystick salvaged from a dud PlayStation controller to analog pin 0 for the player control (left bat). The press-switch on the joystick acts as the coin acceptor switch. I wrote a simple AI to control the right-hand bat. The tricky part was making the AI good enough to be interesting without making it so good that you can't beat it!
The Arduino has 2k of RAM, half of which is used for the 128x64 pixel frame buffer. All drawing functions write into this buffer, and then a function 'updscreen()' transfers the buffer to the OLED over an SPI interface. I've used a similar architecture with mobile-phone-type LCD screens. The processor in the Arduino runs at 16MHz, but is still amply fast enough for this kind of game.
I connected an analog joystick salvaged from a dud PlayStation controller to analog pin 0 for the player control (left bat). The press-switch on the joystick acts as the coin acceptor switch. I wrote a simple AI to control the right-hand bat. The tricky part was making the AI good enough to be interesting without making it so good that you can't beat it!
The Arduino has 2k of RAM, half of which is used for the 128x64 pixel frame buffer. All drawing functions write into this buffer, and then a function 'updscreen()' transfers the buffer to the OLED over an SPI interface. I've used a similar architecture with mobile-phone-type LCD screens. The processor in the Arduino runs at 16MHz, but is still amply fast enough for this kind of game.