MIL-002: Adopt the game #24
@@ -17,9 +17,10 @@ This repository continues
|
|||||||
[020-snake-game](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/020-snake-game)
|
[020-snake-game](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/020-snake-game)
|
||||||
and starts from its finished game; `docs/project-plan.md` tells how the work is split.
|
and starts from its finished game; `docs/project-plan.md` tells how the work is split.
|
||||||
|
|
||||||
> **Status:** the project foundation is in place (environment, constants, tests,
|
> **Status:** the game is in the repository: `python -m snake_game` plays the whole
|
||||||
> source documentation, continuous integration). The game itself, `python -m
|
> game, adopted from the finished game of 020 together with its tests. The next
|
||||||
> snake_game`, is added by the next milestone, `MIL-002`.
|
> milestone, `MIL-003`, checks it against the day-21 lectures and finishes this
|
||||||
|
> README.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -84,9 +85,27 @@ With the virtual environment active:
|
|||||||
python -m snake_game
|
python -m snake_game
|
||||||
```
|
```
|
||||||
|
|
||||||
The game is not in the repository yet: `python -m snake_game` works once `MIL-002`
|
It opens a black 600 by 600 window titled "My Snake Game". The snake of three
|
||||||
is merged, and this section is then completed with the keys, the food, the score
|
white squares starts in the middle and moves to the right by itself, 20 pixels
|
||||||
and the game-over rules.
|
every 0.1 seconds.
|
||||||
|
|
||||||
|
| Key | Effect |
|
||||||
|
| --- | --- |
|
||||||
|
| Up, Down, Left, Right | Turn the snake |
|
||||||
|
|
||||||
|
The snake never turns straight back onto itself: the arrow key opposite to the
|
||||||
|
way it is going is ignored, even when two keys are pressed within one move.
|
||||||
|
|
||||||
|
A small blue circle, the food, appears at a random place. When the head comes closer
|
||||||
|
to it than 15 pixels the snake eats it: the food moves to a new random place, the
|
||||||
|
snake grows by one segment, and the score at the top of the window goes up by 1
|
||||||
|
(`Score: 0`, `Score: 1`, ...).
|
||||||
|
|
||||||
|
The game is over when the head passes the wall (more than 280 pixels from the centre
|
||||||
|
on any side) or touches the tail (comes closer than 10 pixels to a segment behind it).
|
||||||
|
The snake stops, the text `GAME OVER` appears in the middle of the window, the score
|
||||||
|
stays where it is, and a click on the window closes it. You can also close the window
|
||||||
|
with its close button at any time.
|
||||||
|
|
||||||
## Run the tests
|
## Run the tests
|
||||||
|
|
||||||
@@ -137,18 +156,19 @@ The HTML is written to `build/doxygen/index.html`. A warning fails the build.
|
|||||||
├── docs/ business case, plan, milestones, reviews
|
├── docs/ business case, plan, milestones, reviews
|
||||||
├── src/snake_game/ the game
|
├── src/snake_game/ the game
|
||||||
│ ├── __init__.py
|
│ ├── __init__.py
|
||||||
│ └── constants.py every constant of the game
|
│ ├── __main__.py starts the game: python -m snake_game
|
||||||
├── tests/ pytest tests
|
│ ├── constants.py every constant of the game
|
||||||
│ └── test_constants.py
|
│ ├── food.py the Food class (inherits from Turtle)
|
||||||
|
│ ├── main.py screen set-up and the main flow
|
||||||
|
│ ├── scoreboard.py the Scoreboard class (inherits from Turtle)
|
||||||
|
│ └── snake.py the Snake class
|
||||||
|
├── tests/ pytest tests (fakes.py holds the fake turtle and screen)
|
||||||
├── Doxyfile source documentation settings
|
├── Doxyfile source documentation settings
|
||||||
├── LICENSE
|
├── LICENSE
|
||||||
├── pyproject.toml project configuration
|
├── pyproject.toml project configuration
|
||||||
└── README.md
|
└── README.md
|
||||||
```
|
```
|
||||||
|
|
||||||
The game modules (`snake.py`, `food.py`, `scoreboard.py`, `main.py`,
|
|
||||||
`__main__.py`) and their tests are added by `MIL-002`.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
GNU Affero General Public License v3.0 only. See [LICENSE](LICENSE).
|
GNU Affero General Public License v3.0 only. See [LICENSE](LICENSE).
|
||||||
|
|||||||
Reference in New Issue
Block a user