From a hardware perspective, all you need is the basic TinyScreen Video Game Kit and, if you want audio, an additional Proto Board TinyShield (or Proto Terminals, or anything that allows you to connect a speaker to the 'duino pins) and the speaker: for this I broke an old mobile phone headphone that had been lying in the dust for years.
If you don't have the Video Game Kit, but just the TinyScreen, you can still play with the screen buttons (you must change a flag in the source code though), so the only really indispensable things are:
- 1 TinyDuino
- 1 TinyScreen
- 1 USB TinyShield, to program and charge the battery (not needed to play)
To add audio, solder like in the pictures (I am very bad at soldering so I'm pretty sure yours will be better).
Pin 8 to 470ohm resistance to speaker to GND. Without the resistance it still works (connecting the speaker directly), but I think it is too loud. If you have a potentiometer, that would be the best.
Another option is to add other resistances like shown here https://raw.githubusercontent.com/LenShustek/arduino-playtune/master/mega_photo.JPG . If you add another resistance to pin 7 (maybe with more ohms) you would be able to play more complex songs with a second track (maybe at a lower volume). I didn't have one at hand, so for now this is it. If you try, let me know.
From a software perspective, all is included below, just upload and run.
# miditones myFile will export
Anyway this is all already included in the sources below, so, unless you want to change the music, you don't have to do anything.
There are two game sizes you can play at:
- small 10x20 full standard tetris field with each block sized 3x3 (20x3=60)
- wide 10x16 shorter field with each block sized 4x4 (16x4=64=tinyscreen height)
With Joystick shield:
- Left joystick: moves left and right, speeds down
- Right joystick: rotates the piece
- Left button: reset game and choose size (press many times)
- Right button: mute audio to survive
Without joystick (using screen buttons)
#define USE_JOY 1 to
#define USE_JOY 0 in source (main file).
- Top right button rotate
- Bottom left and bottom right together, mute audio to survive
Ideas that should be added to this project, in random order...
- Implement high scores handling, maybe saving to EPROM (kept at shutdown).
- Implement game "noises" other than the background music (pieces dropped, lines cleared, etc..).
- Add a way to pause the game!
- Implement better background music (with two or more tracks) soldering more resistances and importing a more complex midi file.
- Better abstraction of inputs and outputs to allow easier porting and change of configurations: for example to flip the screen upside down (i.e. to put in smartwatch kit) you also need to flip the buttons, and this now means editing the main game loop.
- Implement a game menu to change options like size, game kind, inputs, show/reset high scores etc..
- Try to auto-detect configuration (availability of Joystick, normal or alternate TinyScreen, etc..)
That's it, if you have installed the CodeBender plugin, and connected your board, you will see a green Run On Arduino button below. Choose the right serial port and platform and click on the button. Have fun.
No preview (download only).
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!