illini_snake package

Submodules

illini_snake.base module

class illini_snake.base.Base[source]

Bases: object

Object that reads information from settings and sets the instances key attributes

illini_snake.food module

class illini_snake.food.Food[source]

Bases: Base

draw(screen)[source]
get_square(screen, snake, game)[source]

resets logo_image and square with randomly generated values

illini_snake.game module

class illini_snake.game.Game[source]

Bases: Base

game_over()[source]
run()[source]
property score: int

returns the length of the snake, calling game.score runs this method

illini_snake.screen module

class illini_snake.screen.Screen[source]

Bases: Base

draw_loading_screen()[source]
draw_score(game)[source]

draw the score in the top left corner of the screen

fill()[source]

fill the entire screen with a background color

flip()[source]

illini_snake.snake module

class illini_snake.snake.Snake(screen)[source]

Bases: Base

KEY_DIRECTIONS = {1073741903: 'right', 1073741904: 'left', 1073741905: 'down', 1073741906: 'up'}
OPPOSITE_DIRECTIONS = {'down': 'up', 'left': 'right', 'right': 'left', 'up': 'down'}
draw(screen)[source]
move(food, screen, game)[source]
process_key_press(keys)[source]

process the keys pressed

illini_snake.square module

class illini_snake.square.Square(x: int, y: int)[source]

Bases: object

OFFSET = array([[-0.5, -0.5],        [ 0.5, -0.5],        [ 0.5,  0.5],        [-0.5,  0.5]])
draw(screen, color, width)[source]

draw a square with given width/color centered in its grid location

draw_image(img, screen, width)[source]

draw a pre-scaled image centered a the grid location

static get_pixel_box(pixel_center, width)[source]

get the four coordinates for where to draw the square of given width

is_collision(other) bool[source]

check if square is at the same location as another square

illini_snake.utils module

illini_snake.utils.get_full_path(rel_path)[source]

given a relative path, join it with the illini_snake DIR

illini_snake.utils.load_logo_file(filepath, width)[source]

load an image from a given filepath, proportionally scale it to a given width

Module contents