Skip to content

Zer0AlmostNull/pysnake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PYSnake

That's a fairly simple snake like game coded in python. With graphical interface made using pygame.

A simple API

It's all that simple to implement own python snake game.

map_width, map_height = 15, 15


game = SnakeWindowed(
    arena_size = (width, height),
    cell_size = 25)

To 'tick' the game you just call a:

direction = Direction.UP

game.tick(direction)

where direction is a predefined point object

class Direction:
    UP = Point(0, -1)
    DOWN = Point(0, 1)
    LEFT = Point(-1, 0)
    RIGHT = Point(1, 0)

In order to draw the game on to the pygame screen object use:

game_offset = (0, 0)

game.draw(screen, game_offset)

You also have an example of the game implementation here.

Files description

game.py - it'a a implementation of main snake-game classes

SnakeWindowed
SnakeBasic

point.py - contains a definition of Point class
subconsole.py - really weird definition of class console class
color_settings.py - contains hardcoded snake color palette used in GameGraphical class


example/main.py - actual snake game implementation
example/game_settings.py - contains settings for the implementation
example/game_state.py - contains games states of the implementation
example/ui.py - contains UIElement python-pygame class for UI


So, If you need to get only snake game API copy to your project's folder following files/folders:
color_settings.py, game.py, assets

GLHF ^-^

About

That's a fairly simple snake like game coded in python. With graphical interface made using pygame.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages