Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions snake/gameMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class MapTile(Enum):
HEAD = 3
BODY = 4
APPLE = 5

HEAD2 = 6
BODY2 = 7

class SnakePlayer(IntEnum):
FIRST = 0
SECOND = 1
Expand All @@ -29,6 +31,8 @@ class GameMap:
emptyColor = (9, 0, 99)
headColor = (29, 135, 37)
bodyColor = (5, 228, 0)
headColor2 = (101, 162, 255)
bodyColor2 = (165, 201, 255)
appleColor = (255, 0, 0)
apples = []
gameMode = GameMode.SINGLE
Expand Down Expand Up @@ -69,6 +73,10 @@ def render(self):
color = GameMap.headColor
elif self.mapContent[i][j] == MapTile.BODY:
color = GameMap.bodyColor
elif self.mapContent[i][j] == MapTile.HEAD2:
color = GameMap.headColor2
elif self.mapContent[i][j] == MapTile.BODY2:
color = GameMap.bodyColor2
elif self.mapContent[i][j] == MapTile.APPLE:
color = GameMap.appleColor
else:
Expand Down Expand Up @@ -97,8 +105,8 @@ def putSnakeOnMap(self):
self.mapContent[self.snakes[SnakePlayer.FIRST].x][self.snakes[0].y] = MapTile.HEAD
if self.gameMode == GameMode.DUAL:
for part in self.snakes[SnakePlayer.SECOND].bodyParts:
self.mapContent[part[0]][part[1]] = MapTile.BODY
self.mapContent[self.snakes[SnakePlayer.SECOND].x][self.snakes[SnakePlayer.SECOND].y] = MapTile.HEAD
self.mapContent[part[0]][part[1]] = MapTile.BODY2 # Player2's Color == Blue
self.mapContent[self.snakes[SnakePlayer.SECOND].x][self.snakes[SnakePlayer.SECOND].y] = MapTile.HEAD2

def checkCollision(self):
if self.mapContent[self.snakes[SnakePlayer.FIRST].x][self.snakes[SnakePlayer.FIRST].y] == MapTile.WALL or self.snakes[SnakePlayer.FIRST].checkBodyCollision() == True:
Expand Down