Giter Site home page Giter Site logo

snake-pygame's Introduction

Snake Eater

A snake game written in Python using the Pygame library.

Installing

Download the Python 3 installer package from the official website and install it, if not installed previously.

Run the following in the terminal to install the Pygame library

pip3 install pygame

Running the application

Download the source code from the repository and run the file just as any other Python script (.py) file.

python3 Snake\ Game.py

The difficulty variable can be changed with the values provided in the comment to set the difficulty level.

The rest of the code is properly commented and self explanatory. Tweaks can be made to change the play style or visuals of the game.

Screenshots

1 Written using PyCharm

2 Active game screen

3 Game over screen

Prerequisites

  • Python
  • Pygame, an open source Python library for making multimedia applications

Authors

  • Rajat Dipta Biswas - Initial work

See also the list of contributors who participated in this project.

Acknowledgements

snake-pygame's People

Contributors

rajatdiptabiswas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

snake-pygame's Issues

list index out of range

Traceback (most recent call last):
File "E:\Python\Snake1\main.py", line 110, in
pygame.draw.rect(game_window, green, pygame.Rect(pos[0], pos[1], 10, 10))
IndexError: list index out of range

Too fast, less colors

Slow down the game by adding a button/ key that can do it for you

The user experience can be enhanced by adding more visuals and starting the game after the user is ready to play.
Also The snake can have a better color scheme.

Maybe when the snake eats an apple; you can make it so that the colour added is randomized or within a specified range which can spice things up. You can try it with the random library:

r,g,b=random.randint(0,255),random.randint(0,255),random.randint(0,255)
#try placing this line ^ in many areas just to see what kind of colors pop up

for pos in snake_body:
# Snake body
# .draw.rect(play_surface, color, xy-coordinate)
# xy-coordinate -> .Rect(x, y, size_x, size_y)
pygame.draw.rect(game_window, (r,g,b), pygame.Rect(pos[0], pos[1], 10, 10))

You can also add Game screens like a main menu or a pause menu and so on

I have made a similar project too, Check it out if you want :)

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.