sakthi-make-it-easy


Namesakthi-make-it-easy JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryA modular Python-based Snake game using the turtle module.
upload_time2024-09-29 18:34:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseMIT
keywords snake-game python-game turtle-module classic-game
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Snake Game

`snake_game` is a Python-based classic Snake game developed using the `turtle` module. The project is organized into modular components for better readability and maintainability, with separate modules handling the game screen, snake movement, food generation, player controls, and the main game logic.

## Features

### 1. Game Screen (`screen.py`)
Manages the game window and updates the visuals.

- **`GameScreen(width, height, bg_color, title)`**: Initializes the game window with customizable dimensions, background color, and title.
- **`update()`**: Refreshes the screen after each frame.
- **`listen()`**: Listens for user keyboard input.
- **`onkey(func, key)`**: Binds a specific key to a function for controlling the snake.

### 2. Snake (`snake.py`)
Handles the snake's appearance, movement, and growth.

- **`Snake(shape, color, start_pos)`**: Initializes the snake with a customizable shape, color, and starting position.
- **`move(distance)`**: Moves the snake based on its current direction.
- **`go_up()`, `go_down()`, `go_left()`, `go_right()`**: Functions to change the snake's direction.
- **`add_segment()`**: Adds a segment to the snake's body when it consumes food.
- **`reset()`**: Resets the snake’s position and clears its segments when it collides.

### 3. Food (`food.py`)
Controls food generation and positioning on the screen.

- **`Food(shape, color, start_pos)`**: Initializes the food object at a random location on the screen.
- **`move(boundary)`**: Repositions the food to a new random location within the game boundary after being eaten.

### 4. Controls (`controls.py`)
Manages player controls and binds keys to snake movement.

- **`Controls(screen, snake)`**: Binds the user’s keyboard inputs (W, A, S, D) to the snake's movement.
- **`setup()`**: Sets up key listeners to control the snake.

### 5. Game Logic (`game.py`)
Manages the overall game flow, collision detection, and food consumption.

- **`Game(screen, snake, food, controls, delay, boundary)`**: Initializes the main game components and manages the game loop.
- **`check_collision()`**: Detects if the snake collides with the game boundary or itself.
- **`check_food_collision()`**: Detects if the snake eats the food.
- **`move_snake()`**: Handles snake movement and body segment shifting.
- **`run()`**: Runs the main game loop, including screen updates and collision checks.

## Installation

Clone the repository and install any dependencies required to run the game.

```bash
git clone https://github.com/yourusername/snake_game.git
```

## Usage

Run the game by executing the `game.py` file:

```bash
python game.py
```

## How to Play

- Use the `W`, `A`, `S`, `D` keys to control the snake's movement.
- The objective is to eat the food that appears on the screen and grow the snake without hitting the boundaries or yourself.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sakthi-make-it-easy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "snake-game, python-game, turtle-module, classic-game",
    "author": null,
    "author_email": "SakthiSelvan <ssakthitselvan7@gmail.com>",
    "download_url": null,
    "platform": null,
    "description": "\r\n# Snake Game\r\n\r\n`snake_game` is a Python-based classic Snake game developed using the `turtle` module. The project is organized into modular components for better readability and maintainability, with separate modules handling the game screen, snake movement, food generation, player controls, and the main game logic.\r\n\r\n## Features\r\n\r\n### 1. Game Screen (`screen.py`)\r\nManages the game window and updates the visuals.\r\n\r\n- **`GameScreen(width, height, bg_color, title)`**: Initializes the game window with customizable dimensions, background color, and title.\r\n- **`update()`**: Refreshes the screen after each frame.\r\n- **`listen()`**: Listens for user keyboard input.\r\n- **`onkey(func, key)`**: Binds a specific key to a function for controlling the snake.\r\n\r\n### 2. Snake (`snake.py`)\r\nHandles the snake's appearance, movement, and growth.\r\n\r\n- **`Snake(shape, color, start_pos)`**: Initializes the snake with a customizable shape, color, and starting position.\r\n- **`move(distance)`**: Moves the snake based on its current direction.\r\n- **`go_up()`, `go_down()`, `go_left()`, `go_right()`**: Functions to change the snake's direction.\r\n- **`add_segment()`**: Adds a segment to the snake's body when it consumes food.\r\n- **`reset()`**: Resets the snake\u2019s position and clears its segments when it collides.\r\n\r\n### 3. Food (`food.py`)\r\nControls food generation and positioning on the screen.\r\n\r\n- **`Food(shape, color, start_pos)`**: Initializes the food object at a random location on the screen.\r\n- **`move(boundary)`**: Repositions the food to a new random location within the game boundary after being eaten.\r\n\r\n### 4. Controls (`controls.py`)\r\nManages player controls and binds keys to snake movement.\r\n\r\n- **`Controls(screen, snake)`**: Binds the user\u2019s keyboard inputs (W, A, S, D) to the snake's movement.\r\n- **`setup()`**: Sets up key listeners to control the snake.\r\n\r\n### 5. Game Logic (`game.py`)\r\nManages the overall game flow, collision detection, and food consumption.\r\n\r\n- **`Game(screen, snake, food, controls, delay, boundary)`**: Initializes the main game components and manages the game loop.\r\n- **`check_collision()`**: Detects if the snake collides with the game boundary or itself.\r\n- **`check_food_collision()`**: Detects if the snake eats the food.\r\n- **`move_snake()`**: Handles snake movement and body segment shifting.\r\n- **`run()`**: Runs the main game loop, including screen updates and collision checks.\r\n\r\n## Installation\r\n\r\nClone the repository and install any dependencies required to run the game.\r\n\r\n```bash\r\ngit clone https://github.com/yourusername/snake_game.git\r\n```\r\n\r\n## Usage\r\n\r\nRun the game by executing the `game.py` file:\r\n\r\n```bash\r\npython game.py\r\n```\r\n\r\n## How to Play\r\n\r\n- Use the `W`, `A`, `S`, `D` keys to control the snake's movement.\r\n- The objective is to eat the food that appears on the screen and grow the snake without hitting the boundaries or yourself.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A modular Python-based Snake game using the turtle module.",
    "version": "1.0.0",
    "project_urls": {
        "Documentation": "https://github.com/yourusername/snake_game/docs",
        "Homepage": "https://github.com/yourusername/snake_game",
        "Issue Tracker": "https://github.com/yourusername/snake_game/issues"
    },
    "split_keywords": [
        "snake-game",
        " python-game",
        " turtle-module",
        " classic-game"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "546e59825032c3e6403191bd331abee6e065da4b0944f1cc14e1f3a0b6939ff7",
                "md5": "cb2d8c1b029a78f12eb1d56d8b37943a",
                "sha256": "34c6838957c525018dab4282c45b6d49528562092f7c8c74fb21046187ec9746"
            },
            "downloads": -1,
            "filename": "sakthi_make_it_easy-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cb2d8c1b029a78f12eb1d56d8b37943a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4996,
            "upload_time": "2024-09-29T18:34:22",
            "upload_time_iso_8601": "2024-09-29T18:34:22.159404Z",
            "url": "https://files.pythonhosted.org/packages/54/6e/59825032c3e6403191bd331abee6e065da4b0944f1cc14e1f3a0b6939ff7/sakthi_make_it_easy-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-29 18:34:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "snake_game",
    "github_not_found": true,
    "lcname": "sakthi-make-it-easy"
}
        
Elapsed time: 1.18381s