Skip to content

afk-echo/snek

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

🐍 Snek

An Open Source Python library for the retro Snake game.

📰 Installation:

Pre-requisites: pygame - can be installed by running pip install pygame

  1. Grab the latest release of snek here.
  2. Place it in your project's local directory.

🗞️ Usage

The snek.Snek object:

from snek import Snek
import pygame

width = 600
height = 450
win = pygame.display.set_mode((width, height))
pygame.display.set_caption("Client")

player = Snek(600, 450, 15) #initialise the window boundaries for the Snek object(required for detecting collisions at the boundary) and delta(increment/decrement value for moving the Snek per frame)

Methods for manipulating the snek.Snek object:

  1. snek.Snek.move(foodPos:list)
player.move([150,150]) #moves the Snek object by the delta value initialised earlier.
  1. snek.Snek.draw(win:pygame.display)
player.draw(win) #draws the Snek object on the specified screen.
  1. snek.Snek.headCollidesWith(collideList:list)
player.headCollidesWith([[0,15], [15,30], [30,225], [90,60]]) #checks if the Snek object's head collides with the co-ordinates given in collideList

About

An open source Python library for the Snake retro game.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages