SnakeGame is a simple game-project created by using PyGame.
📚 Click to see libraries were additionaly used in this project
-
enum used to create custom Enum classes
Click to see code
class Direction(Enum): NONE = 0 LEFT = 1 UP = 2 RIGHT = 3 DOWN = 4 class EntityType(Enum): NONE = 0 GRASS = 1 FENCE = 2 ANGLED_FENCE = 3 SNAKE_HEAD = 4 SNAKE_BODY = 5 YAMMY = 6
-
random used to randomly place yammy
Click to see code
def get_random_free_coordinates(self): x, y = 0, 0 while self.cells[x][y].entityType != EntityType.GRASS: x, y = randint(1, 8), randint(1, 8) return x, y
-
os used to correctly define assets path regardless of operating system
Click to see code
PICKUP_SOUND = pygame.mixer.Sound(os.path.join("Assets", "pickup.wav")) HIT_SOUND = pygame.mixer.Sound(os.path.join("Assets", "hit.wav")) GRASS_IMAGE = pygame.image.load(os.path.join("Assets", "grass.png")) FENCE_IMAGE = pygame.image.load(os.path.join("Assets", "fence_straight.png")) ANGLED_FENCE_IMAGE = pygame.image.load(os.path.join("Assets", "fence_angled.png")) SNAKE_HEAD_IMAGE = pygame.image.load(os.path.join("Assets", "snake_head.png")) SNAKE_HEAD_DEAD_IMAGE = pygame.image.load(os.path.join("Assets", "snake_head_dead.png")) SNAKE_BODY_IMAGE = pygame.image.load(os.path.join("Assets", "snake_body.png")) YAMMY_IMAGE = pygame.image.load(os.path.join("Assets", "yammy.png"))
All the assets were drawn by myself. Each asset matches the 64*64 size.
🖼️ Click to see Assets
- End screen
- Win screen
- Angled snake
- Score system