# Pong on ATtiny85
A playable Pong game running on an ATtiny85 with a 128x64 SSD1306 OLED display. Built with [ssd1306xled](https://github.com/tejashwikalptaru/ssd1306xled).
The whole game fits in 3.1 KB of flash and 80 bytes of RAM.
## How to play
- Drag the **slide potentiometer** to move your paddle (right side)
- Press the **button** (or spacebar) to start and restart
- First to 5 wins
The left paddle is controlled by a simple AI that tracks the ball with a slight delay, so it's beatable.
## What happens
- Ball bounces off the top and bottom edges and off paddles
- Hit angle changes depending on where the ball strikes your paddle -- edges give steeper angles, center keeps it flat
- Ball speeds up with each paddle hit
- Buzzer clicks on bounces and plays short tunes on scoring and game end
- Dashed center line redraws itself after the ball passes through
## How it renders
The SSD1306 has no read-back over I2C, so the game uses erase-then-draw for each moving object. Paddles and ball are drawn with raw byte writes to specific display pages and columns -- no framebuffer, no sprites stored in flash. The paddle shape is computed on the fly from its Y position using bit masks across up to 3 display pages.
The ball is 2x2 pixels. Paddles are 2x12 pixels. All positions are pixel-level, not page-aligned.
## About ssd1306xled
A lightweight OLED driver for ATtiny85 and other memory-constrained AVR microcontrollers. Bit-bangs I2C through the USI peripheral instead of using the Wire library, saving about 1 KB of flash.
- Source and docs: https://github.com/tejashwikalptaru/ssd1306xled
- API reference: https://tejashwikalptaru.github.io/ssd1306xled/
- More examples and games: https://github.com/tejashwikalptaru/ssd1306xled/tree/master/examples