
MiniLD #58compo
πng
Pong written in Java displayed on SSD1306-powered SPI display connected to Raspberry Pi. Who has got that?! The game is controlled by two buttons connected to Pi GPIO (the second player is "AI" if you can call it this way).
It probably has got a lot of bugs, but I've written it in like 4 hours (yea, let's use 4 hours of 10 days).
The code is actually pretty lame (at least the actual game, SSD1306 library is my port of Adafruit's Python library which is not that bad), so if you want to see it, send me a message. But who would want to see it :D
If you would want to run it, you would need
SSD1306 128x64 SPI display connected to Raspberry Pi SPI dev 0.1
Two buttons connected to ground (it uses internal pull-up). You would also need Pi4J library installed. Then you can run
sudo java -cp "/opt/pi4j/lib/pi4j-core.jar:./SSD1306.jar:." eu.ondryaso.ssd1306.examples.Pong
By default, GPIO 0 is used for UP button, GPIO 1 for DOWN button, GPIO 3 for RST pin of display and GPIO 4 for D/C pin of display (USING WIRINGPI NUMBERING). You can change this by passing arguments -
sudo java -cp "/opt/pi4j/lib/pi4j-core.jar:./SSD1306.jar:." eu.ondryaso.ssd1306.examples.Pong "GPIO 0" "GPIO 1" "GPIO 3" "GPIO 4" 1.6 1.4 5 1
The numbers stand for player speed, computer speed, ball X speed and ball Y speed. Enjoy!
It probably has got a lot of bugs, but I've written it in like 4 hours (yea, let's use 4 hours of 10 days).
The code is actually pretty lame (at least the actual game, SSD1306 library is my port of Adafruit's Python library which is not that bad), so if you want to see it, send me a message. But who would want to see it :D
If you would want to run it, you would need
SSD1306 128x64 SPI display connected to Raspberry Pi SPI dev 0.1
Two buttons connected to ground (it uses internal pull-up). You would also need Pi4J library installed. Then you can run
sudo java -cp "/opt/pi4j/lib/pi4j-core.jar:./SSD1306.jar:." eu.ondryaso.ssd1306.examples.Pong
By default, GPIO 0 is used for UP button, GPIO 1 for DOWN button, GPIO 3 for RST pin of display and GPIO 4 for D/C pin of display (USING WIRINGPI NUMBERING). You can change this by passing arguments -
sudo java -cp "/opt/pi4j/lib/pi4j-core.jar:./SSD1306.jar:." eu.ondryaso.ssd1306.examples.Pong "GPIO 0" "GPIO 1" "GPIO 3" "GPIO 4" 1.6 1.4 5 1
The numbers stand for player speed, computer speed, ball X speed and ball Y speed. Enjoy!
Comments2

leondryaso1 Apr 2015, 17:00
It's actually a really cheap 0.96' SPI OLED from eBay, the Adafruit one is enormously expensive :D


http://www.adafruit.com/products/661 ?
I really need to try those tiny fruits... GG btw !