Skip to content

Im-Rises/TetrisSFML

Repository files navigation

TetrisSFML

cmakeLogo cppLogo sfmlLogo

Description

Tetris game written in C++ using SFML 2.5.1 lib available for windows, linux and macOS.

The project is compiled using CMake and VisualStudio compiler version.

Features

  • Difficulty increasing depending on your score
  • Clearing row animation
  • Tetromino preview display
  • Soft and Hard drop

Images

Screenshot 1 Screenshot 2
screen1 screen2

Quickstart

To download the game, you can click one of the icons below depending on your operating system, or you can click the release section of the GitHub page.

Depending on you operating system you will need to install some libs, they are installed differently depending on your system, please follow one of the section below Windows or Linux or MacOs.

Note Be carefully you have the Text Font Arial in the folder font next to the executable. Without it the game will crash.

Windows

cmakeLogo

For Windows users you don't need to install the libs, you just need to be carefully that you have the *.dll next to the TetrisSFML.exe or the game won't start.

Once everything is set up by you can start the game by double-clicking the executable of typing the following command next to it:

.\TetrisSFML.exe

Linux

cmakeLogo

For Linux users, you need to install the SFML lib, to do so type one of the following commands:

sudo apt-get install libsfml

or if you're a developer and want to compile the game, please install this version of SFML:

sudo apt-get install libsfml-dev

Then you can start by double-clicking the executable of typing the following command next to it:

./TetrisSFML

MacOs

cmakeLogo

For macOS users you will need to install Brew, please follow the instruction in the link below:
https://brew.sh

Once it is installed, you can type the following command to install SFML.

brew install sfml

Then you can start by double-clicking the executable of typing the following command next to it:

./TetrisSFML

Game controls

To play the game, you need to use your keyboard with the following controls:

Description Keyboard
Hard Drop
Soft Drop
Rotate clockwise S
Rotate counter clockwise D

Project architecture

TetrisSFML
├── .github
|  ├── labels.yml
|  ├── release.yml
│  ├── workflows
│  │   |── cmake.yml
│  │   |── codeql.yml
│  │   |── cpp-cmake-publish.yml
│  │   |── cpp-linter.yml
│  │   |── dependency-review.yml
│  │   |── flawfinder.yml
│  │   |── greetings.yml
│  │   |── label.yml
│  │   |── msvc.yml
│  │   |── stale.yml
├── font
|   ├── arrial.ttf
├── TetrisSFML
|  ├── bin
│  │   |── *
|  ├── include
│  │   |── GLFW
│  │   │   |── *
|  ├── lib
│  │   |── *
|  ├── CMakeLists.txt
|  ├── global.h
|  ├── main.cpp
|  ├── Tetris.cpp
|  ├── Tetris.h
|  ├── Tetromino.cpp
|  ├── Tetromino.h
├── .clang-format
├── .editorconfig
├── .gitaattributes
├── .gitignore
├── CMakelists.txt
├── README.md

Compilation

To compile the game, the first thing you need to do is installing a C++ compiler:

  • Visual Studio (MSVC)
  • Mingw
  • ...

You also need to install Cmake:
https://cmake.org

Once your environment is set up, you can download the project. If you have the Visual Studio compiler then you can directly go to the operating system step compilation in the other case follow, the SFML installation in the SFML section below.

SFML

Follow this guide to install SFML on your distribution.
https://www.sfml-dev.org/tutorials/2.5/

I compile the program with Visual Studio CMake compiler, so I downloaded the Visual C++ 15 (2017) - 64-bit v2.5.1. If you want to compile the app with Mingw, be sure to download the GCC 7.3.0 MinGW (SEH) - 64-bit v2.5.1 and replace the folders bin, include and lib by the mingw one.

Windows

Windows users can directly compile the project by typing the following command at the project root folder:

cmake .

Linux

First thing to do is to install CMake, type the following command to install it.

sudo apt-get install cmake

You also need to install the SFML lib. Type the following command at the project root.

sudo apt-get install libsfml-dev

You are now able to compile the project. Go to the project root and type the following command:

cmake .

MacOs

For macOS user, you should install brew package manager by following the instructions in the link below:
https://brew.sh

Then type the following command to install cmake:

brew install cmake

and this one to install SFML

brew install sfml

You are now able to compile the project. Go to the project root and type the following command:

cmake .

Github-Actions

flawfinder CMake CodeQL Microsoft C++ Code Analysis Cpp Cmake Publish cpp-linter

The project is set with a set of different scripts:

  • flawfinder : to check the code for security flaws
  • CMake : to compile the project
  • CodeQl : to check quality of the code
  • Microsoft C++ Code Analysis : to check the code for security flaws
  • Cpp Cmake Publish : to publish the project on GitHub

Documentations

Main documentation:
https://www.youtube.com/watch?v=vkS1fY_UTyg&t=1s

Tetris Wiki:
https://tetris.fandom.com/wiki/SRS

SFML:
https://github.com/SFML/SFML

Contributors

Quentin MOREL :

GitHub contributors