Arduino Tetris: Difference between revisions

From Adam Colton
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Use an Arduino pro mini with a Nokia display and a few simple push buttons. The whole thing should be tiny, just a few inches and should be able to run for a long time off a single battery.
Use an Arduino pro mini with a Nokia display and a few simple push buttons. The whole thing should be tiny, just a few inches and should be able to run for a long time off a single battery.
I'm going to build the board for tetris, but I'll add isp pins exposed so I can reprogram it.


== Power ==
== Power ==
For power, there are 3.3v setup converts that can take the power from a single AAA battery and step it up to 3.3v. I want to add a mosfet and a button. The button will power-on the board, if the power button is held down long enough for the Arduino to power up (about 1 second), the Arduino will set a pin high to power the mosfet, which will keep power flowing. When the game is over, the Arduino will power itself off.
For power, there are 3.3v setup converts that can take the power from a single AAA battery and step it up to 3.3v. I want to add a mosfet and a button. The button will power-on the board, if the power button is held down long enough for the Arduino to power up (about 1 second), the Arduino will set a pin high to power the mosfet, which will keep power flowing. When the game is over, the Arduino will power itself off.
I could also use a soft latch push button.


== Display ==
== Display ==
Line 12: Line 16:


== Controls ==
== Controls ==
Controls will be 3 buttons on the right (← ↓ →), and two buttons on the left to rotate right and left. I may add an ↑ button just so that I could put another game on it later.
Controls will be 4 buttons on the left (← ↓ → ↑), and two buttons on the right to rotate right and left. The ↑ button is just so that I could put another game on it later.


== Case ==
== Case ==
Line 26: Line 30:


The multiplier is added and reset when a piece lands without clearing a row. So clearing 4 lines get 27 points and sets the multiplier to 3, if the next piece clears 1 line, that get 3 points and leaves the multiplier at 3, if the next piece clears 3 lines, that gets 27 points and increases the multiplier to 4. If the next piece clears no lines, the multiplier is reset to 1. The multiplier cannot exceed two digits. The highest it could get is 5 successive tetris, which would only reach 15. So the first digit cannot get above 1.
The multiplier is added and reset when a piece lands without clearing a row. So clearing 4 lines get 27 points and sets the multiplier to 3, if the next piece clears 1 line, that get 3 points and leaves the multiplier at 3, if the next piece clears 3 lines, that gets 27 points and increases the multiplier to 4. If the next piece clears no lines, the multiplier is reset to 1. The multiplier cannot exceed two digits. The highest it could get is 5 successive tetris, which would only reach 15. So the first digit cannot get above 1.
== Program ==
The board can be represented as a 25B array.
Drawing is going to be a pain because the board is sideways. But I want to write the draw routines myself. I should be able to track dirty bytes and only update those, since most of the screen won't change from turn to turn.
I can also store high scores in EEPROM. I won't save anything like name or initials, just a list of the top 5 scores. I'll show them when the game boots up and at the end of the game. And a special screen if you get a high score.


[[Category:Electronics]]
[[Category:Electronics]]

Latest revision as of 14:35, 11 October 2018

Use an Arduino pro mini with a Nokia display and a few simple push buttons. The whole thing should be tiny, just a few inches and should be able to run for a long time off a single battery.

I'm going to build the board for tetris, but I'll add isp pins exposed so I can reprogram it.

Power

For power, there are 3.3v setup converts that can take the power from a single AAA battery and step it up to 3.3v. I want to add a mosfet and a button. The button will power-on the board, if the power button is held down long enough for the Arduino to power up (about 1 second), the Arduino will set a pin high to power the mosfet, which will keep power flowing. When the game is over, the Arduino will power itself off.

I could also use a soft latch push button.

Display

Nokia 5110 display.

The game will be a 10x20 grid, each cell having 3 pixels. The display is 84x48, but I'll use it sideways. The game board will take up 60x30 with a 3px border. This should leave room across the bottom for the score and off to one side to show the next piece and the multiplier.

I also want to include a photo-diode near the screen and adjust the brightness automatically.

Controls

Controls will be 4 buttons on the left (← ↓ → ↑), and two buttons on the right to rotate right and left. The ↑ button is just so that I could put another game on it later.

Case

I'm not sure what I want to do about a case. I kind of want to keep everything visible so I can show off the build. But I need to protect the circuitry, so I may just put some clear plastic on the back. Maybe just clear plastic from a pop bottle.

I want to glue some female headers onto the edge of the perf board and connect those to the program pins on the Arduino so that I can re-program the board.

Score

  • 1 : 1
  • 2 : 3
  • 3 : 9 X = +1
  • 4 : 27 X = +3

The multiplier is added and reset when a piece lands without clearing a row. So clearing 4 lines get 27 points and sets the multiplier to 3, if the next piece clears 1 line, that get 3 points and leaves the multiplier at 3, if the next piece clears 3 lines, that gets 27 points and increases the multiplier to 4. If the next piece clears no lines, the multiplier is reset to 1. The multiplier cannot exceed two digits. The highest it could get is 5 successive tetris, which would only reach 15. So the first digit cannot get above 1.

Program

The board can be represented as a 25B array.

Drawing is going to be a pain because the board is sideways. But I want to write the draw routines myself. I should be able to track dirty bytes and only update those, since most of the screen won't change from turn to turn.

I can also store high scores in EEPROM. I won't save anything like name or initials, just a list of the top 5 scores. I'll show them when the game boots up and at the end of the game. And a special screen if you get a high score.