snake_game

Snake Game in Python (No Pygame)

Project Description

This project is a classic Snake game implemented in Python, built without the use of external libraries like Pygame. The game runs in the terminal/console, allowing users to control a snake, eat food, and grow longer while avoiding collisions with walls or itself.

Features

Technologies Used

How to Run the Project

  1. Install Python: Ensure that you have Python installed on your machine. You can download it from here.

  2. Clone the repository:

    git clone https://tomwooly.github.io/snake_game/

  3. Navigate to the project directory:

    cd snake-game

  4. Run the game:

    python snake_game.py

Code Overview

The code consists of the following key components:

  1. Game Grid: The snake and food are displayed on a grid that is rendered in the console. The grid updates with each move.
  2. Snake Movement: The snake’s movement is controlled by keyboard input. The user can navigate the snake with the arrow keys (or WASD keys).
  3. Food Generation: Food is randomly generated within the grid boundaries.
  4. Collision Detection: The game checks for collisions between the snake and the walls or itself, triggering the game over state.
  5. Game Loop: The game continuously runs in a loop, handling updates for the snake’s movement, rendering the grid, and processing user input.

Sample Code Snippets

Project Demo

You can view a demo of the game running in the terminal [here].

Future Enhancements

Acknowledgments