• Your repository must contain the totality of your source files, but no useless files (binary, temp files,
obj files,...).
• All the bonus files (including a potential specific Makefile) should be in a directory named bonus.
• Error messages have to be written on the error output, and the program should then exit with the
84 error code (0 if there is no error).
Authorized functions: rand, srand, getopt, and all functions used for PSU projects until this point
The goal of this project is to recreate the Tetris game in a UNIX terminal, with the Gameboy version rules. You have
to use ncurses.
In the folder of your binary, there must be a tetriminos directory, which contains files that describe the game pieces.
∇
Terminal
- + x
∼/B-PSU-155&gt; ls ./tetriminos/
bar.tetrimino
square.tetrimino
5.tetrimino
7.tetrimino
inverted-L.tetrimino
4.tetrimino
6.tetrimino
These files are composed in the following way:
1. on the first line, the size and color of the piece in this format: width height color_code\n (the number of
the color corresponds to the ncurses capacity’s color numbers),
2. on the h following lines (where h is the height of the tetrimino), the piece’s shape composed with asterisks (*)
and spaces (’ ’).
∇
Terminal
∼/B-PSU-155&gt; cat -e bar.tetrimino
1 4 2$
* $
* $
*$
* $

For instance, these pieces correspond to the opposite
files:

∼/B-PSU-155&gt; cat -e 6.tetrimino
2 3 6$
**$
*$
**$

1

- + x

The pieces (randomly chosen) fall from the top of the map and pile up on the bottom. Each time a line is completed,
it disappears, leaving all of the pieces above it to fall.
The level increases by 1 for every 10 deleted lines. The falling speed increases proportionally to the level.
When it is no longer possible for pieces to fall from the top of the map, the player loses.

You can find the full gamerules here.

When the game begins, the terminal must delete all content. Then, it must show (at least):
• the main map,
• a preview of the next tetrimino to fall,
• current score, high score, current number of completed lines, level, timer.
If the terminal is too small to host the map, the game do not start; an error message is printed, asking the user to
enlarge his/her terminal.
For the gameplay, refer to the following usage:
∇
Terminal
- + x
∼/B-PSU-155&gt; ./tetris --help | cat -e
Usage: ./tetris [options]$
Options:$
--help
Display this help$
-l --level={num}
Start Tetris at level num (def: 1)$
-kl --key-left={K}
Move the tetrimino LEFT using the K key (def: left arrow)$
-kr --key-right={K} Move the tetrimino RIGHT using the K key (def: right arrow)$
-kt --key-turn={K}
TURN the tetrimino clockwise 90d using the K key (def: top arrow)$
-kd --key-drop={K}
DROP the tetrimino using the K key (def: down arrow)$
-kq --key-quit={K}
QUIT the game using the K key (def: ’q’ key)$
-kp --key-pause={K} PAUSE/RESTART the game using the K key (def: space bar)$
--map-size={row,col} Set the numbers of rows and columns of the map (def: 20,10)$
-w --without-next
Hide next tetrimino (def: false)$
-d --debug
Debug mode (def: false)$

Bonus
Many nice bonus points are possible.
Unleash your imagination, and have fun:
• save the round to play again later,
• save High Scores with player names (hall of fame),
• High Score board,
• miscellaneous animations,
• music and sound effects,
• multi-player game (cf tetriNET for instance).