Mercurial > rinkhals
comparison gamelib/gameboard.py @ 323:978efd39a099
Limit maximum numbe of foxes generated
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 21:30:18 +0000 |
parents | 9bf0e701a36e |
children | b07ea17b8b4e |
comparison
equal
deleted
inserted
replaced
322:f8e9a8851d7d | 323:978efd39a099 |
---|---|
320 def __init__(self, main_app): | 320 def __init__(self, main_app): |
321 self.disp = main_app | 321 self.disp = main_app |
322 self.tv = tiles.FarmVid() | 322 self.tv = tiles.FarmVid() |
323 self.tv.png_folder_load_tiles('tiles') | 323 self.tv.png_folder_load_tiles('tiles') |
324 self.tv.tga_load_level(data.filepath('levels/farm.tga')) | 324 self.tv.tga_load_level(data.filepath('levels/farm.tga')) |
325 height, width = self.tv.size | |
326 # Ensure we don't every try to create more foxes then is sane | |
327 self.max_foxes = min(height+width-15, constants.ABS_MAX_NUM_FOXES) | |
325 self.create_display() | 328 self.create_display() |
326 | 329 |
327 self.selected_tool = None | 330 self.selected_tool = None |
328 self.animal_to_place = None | 331 self.animal_to_place = None |
329 self.sprite_cursor = None | 332 self.sprite_cursor = None |
983 """The foxes come at night, and this is where they come from.""" | 986 """The foxes come at night, and this is where they come from.""" |
984 # Foxes spawn just outside the map | 987 # Foxes spawn just outside the map |
985 x, y = 0, 0 | 988 x, y = 0, 0 |
986 width, height = self.tv.size | 989 width, height = self.tv.size |
987 min_foxes = (self.days+3)/2 # always more than one fox | 990 min_foxes = (self.days+3)/2 # always more than one fox |
988 new_foxes = random.randint(min_foxes, min_foxes*2) | 991 new_foxes = min(random.randint(min_foxes, min_foxes*2), self.max_foxes) |
989 while len(self.foxes) < new_foxes: | 992 while len(self.foxes) < new_foxes: |
990 side = random.randint(0, 3) | 993 side = random.randint(0, 3) |
991 if side == 0: | 994 if side == 0: |
992 # top | 995 # top |
993 y = -1 | 996 y = -1 |