-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathState.py
More file actions
32 lines (27 loc) · 818 Bytes
/
Copy pathState.py
File metadata and controls
32 lines (27 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Author : Milan Marocchi
Date : 10/02/2021
Purpose : Contains code for the Base state for the snake game
"""
class State():
"""
class : State
purpose : A Base class for one of the two states, AI or Player.
"""
def __init__(self, game, blockSize):
"""
Creates an instance of State (Only called by children)
:param game: A pointer to the game object
:param blockSize: Size of the pixels
"""
self.game = game
self.BLOCKSIZE = blockSize
def processFood(self):
"""
Processes the food to see if collided with snack (snake)
"""
if self.snake.getHead() == self.game.food:
self.score += 1
self.game._placeFood()
else:
self.snake.popBody()