-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimal.py
25 lines (20 loc) · 830 Bytes
/
animal.py
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
import os
import random
import game_config as gc
from pygame import image, transform
animals_count = dict((a, 0) for a in gc.ASSET_FILES)
def available_animals():
return [a for a, c in animals_count.items() if c < 2]
class Animal:
def __init__(self, index):
self.index = index
self.row = index // gc.NUM_TILES_SIDE
self.col = index % gc.NUM_TILES_SIDE
self.name = random.choice(available_animals())
animals_count[self.name] += 1
self.image_path = os.path.join(gc.ASSET_DIR, self.name)
self.image = image.load(self.image_path)
self.image = transform.scale(self.image, (gc.IMAGE_SIZE -2*gc.MARGIN, gc.IMAGE_SIZE -2*gc.MARGIN))
self.box = self.image.copy()
self.box.fill((200, 200, 200))
self.skip = False