Coder Social home page Coder Social logo

tkhiienlok / snake-pygame Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 9.0 162 KB

This is a basic version of snake game. As it moves forward, it leaves a trail behind, resembling a moving snake. The player loses when the snake runs into the screen border or itself. A sole player attempts to eat apples by running into them. Each apple eaten makes the snake longer.

Python 100.00%
pygame-games tkinter-gui snake-game snake-pygame oop oop-python classes-and-objects

snake-pygame's Introduction

Snake-Pygame

This is a basic version of snake game. As it moves forward, it leaves a trail behind, resembling a moving snake. The player loses when the snake runs into the screen border (there are four walls around the screen) or itself. Snake has 5 lives. A sole player attempts to eat apples by running into them. Each apple eaten makes the snake longer and adds points. Big apples give more points.

As you run a program first the popup window shows up asking to enter the name of the player. By the end of the game the results (player's name, apples amount, points) are written to the .txt file.

The control keys are:

  • "up"
  • "down"
  • "left"
  • "right".

Double press makes the snake to speed up.

Used libraries:

  • pygame
  • kivy

Setup

Pre-requirements:

  • python 3.9 >
  • virtualenv

Install virtualenv

pip install virtualenv

On Windows OS you need to add virtualenv installation path into PATH environment variable of the system. Example tutorial on that

Virtual Environment

If you would like to use virtualenv

Create virtual environment. From the root directory run.

virtualenv snakegameenv

where "snakegameenv" is the custom name of the environment

Activate the environment

On Windows you need this command:

<environment name>\Scripts\activate

in our case:

snakegameenv\Scripts\activate

On Unix system

source snakegameenv/bin/activate

Install requirements

pip install -r requirements.txt

Instead of virtualenv you can use conda

Create and activate environment:

conda create --name Snake-Pygame  python=3.10
conda activate Snake-Pygame

Install packages:

conda install --file requirements.txt

Before commit

Save all installed packages to the list of requirements:

With pip

pip freeze > requirements.txt

With conda

conda list --export > requirements.txt

Run the app

In the terminal run

python ./src/main.py

In PyCharm with Run button in the top menu

run_project.png.png

snake-pygame's People

Contributors

electricalgorithm avatar tkhiienlok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.