engine.field documentation - wladekpal/The-Lazy-Snek GitHub Wiki
engine.field.Field
Field class that holds field information, including blocks and snakes located on it. It also simulates blocks and snakes relocation.
Properties:
coordinates
- coordinate pair holding field location on board.board
-engine.board.Board
object that field is located on.flat_layer
-engine.blocks.Flat
object that is located on field.convex_layer
-engine.blocks.Convex
object that is located on field.snake_layer
-engine.snake.Snake
object that has it's segment on field.texture
-pygame.image
object holding texture.
Constructor
Takes coordinates
. Constructor method, sets class attributes and loads texture.
give_field_in_direction(direction)
Method used to give field located in direction given as parameter.
set_board(board)
Method used to set board attribute.
check_snake_move(snake)
Method that returns True
if snake can enter the field, False
otherwise.
snake_entered(snake)
Method that simulates snake enterance.
If there was already snake on field, it interacts with snake that entered.
Otherwise, if there was convex on field, convex interacts with snake.
If there was flat on field, but there was no snake, flat interacts with snake that entered.
If snake that entered didn't die in process, snake_layer
is being set to snake.
snake_left()
Method used to remove snake from field after it left by performing a move.
remove_snake(snake)
Method used to remove snake from field.
place_snake(snake)
Method used to place snake segment on field
remove_flat()
Method used to remove flat from field.
place_flat(flat)
Method used to place flat on field.
check_convex_move(direction)
Method that returns True
if convex can enter the field, False
otherwise.
convex_entered(convex, direction)
Method that simulates convex enterance.
If there was already snake on field, it interacts with convex that entered.
Otherwise, if there was convex on field, it interacts with convex that entered.
If there was flat on field, it interacts with convex that entered.
Method also updates convex_layer
attribute, and sets convex's field
attribute.
convex_left(direction)
Method used to remove convex from field after it left by being moved.
remove_convex()
Method used to remove convex from field.
place_convex(convex)
Method used to place convex on field.
self_draw(frame, draw_coords, side_length)
Method used to display field on screen. First, it draws field itself, then flat layer, then snake layer, finally convex layer, if those are present.