A Tetris game running in the Linux terminal.
- Install CMake.
- Install GoogleTest.
- Install ncurses.
Set the location to the project folder and run:
mkdir build
cd build
cmake -DTETRIS_BUILD_TESTS=ON ..
cmake --build .
Set the location to the build
folder and run:
ctest -VV
Set the location to the build/bin
folder and run:
./tetris -x=<width> -y=<height>
For example:
./tetris -x=10 -y=15
.
├── .clang-format
├── .gitignore
├── CITATION.cff
├── CMakeLists.txt
├── Dockerfile
├── LICENSE
├── README.md
├── cover.png
├── docs
│ └── badges
│ ├── C++.svg
│ ├── License-MIT.svg
│ ├── Linux.svg
│ ├── Made-with-CMake.svg
│ ├── Made-with-GitHub-Actions.svg
│ └── Made-with-Docker.svg
├── include
│ ├── args.h
│ ├── color.h
│ ├── controller.h
│ ├── game.h
│ ├── grid.h
│ ├── location.h
│ ├── rotation.h
│ ├── shape.h
│ └── tetromino.h
├── src
│ ├── CMakeLists.txt
│ ├── args
│ │ ├── CMakeLists.txt
│ │ └── args.cpp
│ ├── color
│ │ ├── CMakeLists.txt
│ │ └── color.cpp
│ ├── controller
│ │ ├── CMakeLists.txt
│ │ ├── controller.cpp
│ │ └── ui
│ │ ├── board.h
│ │ ├── color_env.cpp
│ │ ├── color_env.h
│ │ ├── grid_board.h
│ │ ├── next_tetromino_board.h
│ │ └── score_board.h
│ ├── game
│ │ ├── CMakeLists.txt
│ │ └── game.cpp
│ ├── grid
│ │ ├── CMakeLists.txt
│ │ └── grid.cpp
│ ├── location
│ │ └── CMakeLists.txt
│ ├── main.cpp
│ ├── rotation
│ │ ├── CMakeLists.txt
│ │ └── rotation.cpp
│ ├── shape
│ │ └── CMakeLists.txt
│ └── tetromino
│ ├── CMakeLists.txt
│ ├── subtype
│ │ ├── i.h
│ │ ├── j.h
│ │ ├── l.h
│ │ ├── o.h
│ │ ├── s.h
│ │ ├── t.h
│ │ └── z.h
│ └── tetromino.cpp
└── tests
├── CMakeLists.txt
├── grid_test.cpp
├── rotation_test.cpp
└── tetromino_test.cpp
classDiagram
class Colored {
<<interface>>
GetColor() Color
SetColor(Color)
}
class Rotatable {
<<interface>>
RotateLeft()
RotateRight()
GetAngle() Angle
RotateTo(Angle)
}
class Locatable {
<<interface>>
GetPosition() Point
}
class Movable {
<<interface>>
SetPosition(Point)
}
Locatable <|-- Movable
class Shape {
<<interface>>
GetHeight() int
GetWidth() int
Filled(Point) bool
}
class Tetromino {
<<abstract>>
GetTetrominoByAngle(Angle) Tetromino
}
Shape <|.. Tetromino
Rotatable <|.. Tetromino
Colored <|.. Tetromino
Tetromino <|-- I
Tetromino <|-- O
Tetromino <|-- J
Tetromino <|-- L
Tetromino <|-- S
Tetromino <|-- T
Tetromino <|-- Z
class Grid {
GetColor(Point) Color
PushTetromino(Tetromino, Point) bool
MoveTetrominoToLeft() bool
MoveTetrominoToRight() bool
RotateTetrominoLeft() bool
RotateTetrominoRight() bool
TetrominoDescend(int& cleared_line_count) bool
}
Shape <|.. Grid
Grid *-- Tetromino
Movable <|.. MovableTetromino
MovableTetromino --> Tetromino
Grid --> MovableTetromino
class Action {
<<enumeration>>
Non
MoveToLeft
MoveToRight
RotateLeft
RotateRight
Descend
}
class Game {
Start()
Act(Action) ActionResult
GetNextTetrominoes() Tetromino
GetScore() int
IsOver() bool
}
Game --> Grid
Game ..> Action
class Controller {
Input()
Update()
Refresh()
}
Controller --> Game
Distributed under the MIT License. See LICENSE
for more information.