Skip to content

adamgreig/arduino_tetris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino Tetris

Hardware

Method

A 10x20 char grid represents the game grid. A struct that holds four two-byte Positions represents the piece in play. The code then loops through, deciding whether to apply gravity each loop based on how long it was since gravity was previously applied, then checking for a collision if so. If a collision happened the current piece is saved to the grid and a new one is generated. The grid is checked for newly completed lines and if any are found they're cleared and the player gets a point. In the meantime, the four buttons are on the pin change interrupt, and drive the move_left, move_right, rotate and drop functions. Interrupts are disabled each time one happens and reenabled after drawing each frame to help stop accidental repeats. At the end of the game, when a block is placed in the top row, the grid is filled with red and then a number of squares are lit up green to represent the player's score. This is problematic with a score of over 200, but that's a pretty unlikely edge case.

About

Play Tetris on an Arduino, using a 128x96 colour LCD and four buttons

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published