-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the LEDTetris wiki!
This project is about controlling a LED Matrix (made out of adressable WS2812b LED-Strips) and implementing some basic Tetris fundamentals (the actual Tetris logic will be done by some other person), like displaying the standard tetris-Blocks, implementng a falling-animation of the block, the possibility to remove a whole row of pixels. The Game will be controlled by some game controllers (I don't know which ones at the moment).
The whole development is done on a Raspberry Pi 3 B2 and written in python.
The LEDs will be controlled using Adafruits Neopixel library, the installation instruction of this library can be found here:
All scripts are programmed using python3 and must run as root!
At first I want to implement the following classes:
- Matrix.py -> creates a Matrix of the LED-adresses and gives the programmer the possibility to manipulate the matrix, so it will fit the actual order of the data line of the LEDs.
- Blocks.py -> creates the standard Tetris-Blocks and returns them as an object.
- Controller.py -> interacts with the controller
- GameBoard.py -> creates the game board and manipulates the Matrix-object
- Colors.py -> provides methods to ouut colored text to the terminal
- Leds.py -> controls the LEDs of the matrix
The project structure is intended to be used the following way: first create a game board by calling the Board-constructor, the board then creates a new matrix as fundament for the game board and manipulates the matrix according to the game logic, so the programmer of the game logic should only use the Board class.
from lib import GameBoard
import board
PIN = board.D18 # GPIO18
VERBOSE = True
X = 8
Y = 15
gBoard = GameBoard.gameboard(X, Y)
m = gBoard.getMatrix()
# invert Matrix horizontally:
if VERBOSE == True:
for y in range(m.Ymax):
m.invert_horizontally(y)
print(m.toString(m.adresses))
gBoard.setAllLeds((0, 0, 0))
print(m.toString())
gBoard.setBlock(0, 5, 'i_block')
gBoard.updateLEDS()
print(m.toString())
gBoard.wait(1)
gBoard.setBlock(1, 3, 'o_block')
gBoard.updateLEDS()
print(m.toString())
gBoard.wait(1)
gBoard.setBlock(2, 6, 'l_block')
gBoard.updateLEDS()
print(m.toString())
gBoard.wait(1)
gBoard.setBlock(3, 3, 'z_block')
gBoard.updateLEDS()
print(m.toString())
gBoard.wait(1)
gBoard.setBlock(4, 10, 't_block')
gBoard.updateLEDS()
print(m.toString())