Mercurial > rinkhals
comparison gamelib/gameboard.py @ 403:c7cfa230f5d4
Remove board size restriction on number of foxes
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Thu, 19 Nov 2009 11:26:55 +0000 |
parents | 7405f7db469f |
children | ae3cee7a1337 |
comparison
equal
deleted
inserted
replaced
402:3a469d46b820 | 403:c7cfa230f5d4 |
---|---|
281 self.tv = tiles.FarmVid() | 281 self.tv = tiles.FarmVid() |
282 self.tv.png_folder_load_tiles('tiles') | 282 self.tv.png_folder_load_tiles('tiles') |
283 self.tv.tga_load_level(level.map) | 283 self.tv.tga_load_level(level.map) |
284 width, height = self.tv.size | 284 width, height = self.tv.size |
285 # Ensure we don't every try to create more foxes then is sane | 285 # Ensure we don't every try to create more foxes then is sane |
286 self.max_foxes = min(2*height+2*width-15, level.max_foxes) | 286 self.max_foxes = level.max_foxes |
287 self.create_display() | 287 self.create_display() |
288 | 288 |
289 self.selected_tool = None | 289 self.selected_tool = None |
290 self.animal_to_place = None | 290 self.animal_to_place = None |
291 self.sprite_cursor = None | 291 self.sprite_cursor = None |
968 x = -1 | 968 x = -1 |
969 y = random.randint(-1, height) | 969 y = random.randint(-1, height) |
970 else: | 970 else: |
971 x = width | 971 x = width |
972 y = random.randint(-1, height) | 972 y = random.randint(-1, height) |
973 skip = False | 973 self.add_fox(self._choose_fox((x, y))) |
974 for other_fox in self.foxes: | |
975 if other_fox.pos.x == x and other_fox.pos.y == y: | |
976 skip = True # Choose a new position | |
977 break | |
978 if not skip: | |
979 self.add_fox(self._choose_fox((x, y))) | |
980 | 974 |
981 def fix_buildings(self): | 975 def fix_buildings(self): |
982 """Go through the level map looking for buildings that haven't | 976 """Go through the level map looking for buildings that haven't |
983 been added to self.buildings and adding them. | 977 been added to self.buildings and adding them. |
984 | 978 |