Skip to content

Commit 2ad29f1

Browse files
committed
Add a README describing steps to write a Tetris game
1 parent cb221f8 commit 2ad29f1

1 file changed

Lines changed: 92 additions & 1 deletion

File tree

README.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,92 @@
1-
# tetris
1+
# London Python Dojo - Tetris
2+
3+
The task for tonight is to create a clone of Tetris. This page lays out some
4+
of the decisions and tasks.
5+
6+
This is an aid to coordinating as a remote team.
7+
8+
9+
# Game engine
10+
11+
You will need to decide on a 2D game framework. Some candidates are:
12+
13+
* [Pygame Zero](https://pygame-zero.readthedocs.io/en/stable/)
14+
* [Wasabi2D](https://wasabi2d.readthedocs.io/en/latest/)
15+
* [Arcade](https://arcade.academy/)
16+
* [PursuedPyBear](https://ppb.dev/)
17+
* [ursina](https://www.ursinaengine.org/)
18+
19+
I would not recommend these for this project:
20+
21+
* [Pygame](https://www.pygame.org/news) - you will have to write a game loop
22+
and event handling yourself before beginning.
23+
* [Pyglet](https://pyglet.readthedocs.io/en/latest/) - being lower-level to
24+
OpenGL, this does not have a simple API for polygon/rectangle drawing, only
25+
sprites and text.
26+
27+
28+
# Tasks
29+
30+
The following tasks are split up according to a "Model-View-Controller"
31+
pattern to make it easier to visualise the dependencies between the tasks,
32+
but this is not the only way (and may not be the best way) to write the game.
33+
34+
35+
## Model
36+
37+
1. Describe the seven tetronimo pieces (as
38+
[described here](https://tetris.fandom.com/wiki/Tetromino)).
39+
1. Generate a random piece. Show the next piece that will be generated.
40+
1. Rotate a tetronimo. This requires a centre of rotation for each tetronimo.
41+
See [here for a description of this in the official games](https://strategywiki.org/wiki/Tetris/Rotation_systems).
42+
1. Model the grid of filled cells.
43+
1. Allow testing whether a tetronimo intersects filled cells at a given
44+
position.
45+
1. Write a tetronimo into the filled cells.
46+
1. Remove each line that is filled and collapse lines above.
47+
1. Keep score.
48+
49+
50+
## View
51+
52+
1. Create a game window.
53+
1. Draw the boundary of the play area.
54+
1. Draw the filled cells.
55+
1. Draw the active tetronimo.
56+
1. Draw the next tetronimo to drop.
57+
1. Animate the removal of a line.
58+
1. Show the score.
59+
1. Allow drawing "game over" over the screen.
60+
61+
62+
## Controller
63+
64+
1. At the start of the game, make the next tetronimo the active tetronimo.
65+
1. Drop one step every *t* seconds. If the tetronimo cannot occupy the space
66+
below it, write it into the filled cells. Trigger an animation if a line is
67+
filled. Then make the next tetronimo active.
68+
1. Add keys for left/right. These do nothing if there is no space for the
69+
tetronimo.
70+
1. Add keys for rotate clockwise/anticlockwise. These do nothing if there is
71+
no space for the rotated tetronimo. At the walls, tetronimos may be moved
72+
outwards to accomodate the rotation.
73+
1. If there is no room to introduce the active piece, show game over.
74+
1. On the game over screen, press a key to restart.
75+
1. Implement the "drop all the way" operation.
76+
77+
78+
## Publication
79+
80+
1. Describe requirements in a requirements.txt
81+
1. Write a README.
82+
83+
84+
## Stretch goals
85+
86+
1. Animate the rotation of the pieces.
87+
1. Animate the drop operation(s).
88+
1. Make the game speed increase very slowly (logarithmically?)
89+
1. Add [juice](https://youtu.be/Fy0aCDmgnxg) - screen shake, trails, particles,
90+
sound effects.
91+
1. Add a title screen.
92+
1. Publish to PyPI.

0 commit comments

Comments
 (0)