diff options
author | matts1 <mattstark75@gmail.com> | 2013-03-24 19:44:48 +1100 |
---|---|---|
committer | matts1 <mattstark75@gmail.com> | 2013-03-24 19:44:48 +1100 |
commit | 7af7c2db8d3eccd0ce6cbfe69635833b5aff6a98 (patch) | |
tree | 19bf4cd86ecfe84b509aa56e7cc0881df8792776 | |
parent | 9050f0c0648c3ef2aa74edbf14504231ee0f8725 (diff) |
added in walls, modified viewers
-rw-r--r-- | snakegame/engine.py | 10 | ||||
-rw-r--r-- | snakegame/images/wall.png | bin | 0 -> 1025 bytes | |||
-rw-r--r-- | snakegame/viewers/pygame.py | 3 | ||||
-rw-r--r-- | snakegame/viewers/pyglet.py | 3 |
4 files changed, 11 insertions, 5 deletions
diff --git a/snakegame/engine.py b/snakegame/engine.py index e4e6799..86e1cc9 100644 --- a/snakegame/engine.py +++ b/snakegame/engine.py @@ -15,7 +15,8 @@ HARD_TIME_LIMIT = 1.0 class Engine(object): def __init__( self, - rows, columns, n_apples, n_ice_creams=0, n_shrink_potions=0, + rows, columns, n_apples, n_ice_creams=0, + n_shrink_potions=0, n_walls=0, wrap=True, random=None, *args, **kwargs @@ -29,7 +30,8 @@ class Engine(object): self.wrap = wrap self.bots = {} - self.new_game(rows, columns, n_apples, n_ice_creams, n_shrink_potions) + self.new_game(rows, columns, n_apples, n_ice_creams, + n_shrink_potions, n_walls) def get_random_position(self): x = self.random.randrange(0, self.columns) @@ -48,7 +50,8 @@ class Engine(object): x, y = self.get_random_position() self.board[y][x] = item - def new_game(self, rows, columns, n_apples, n_ice_creams, n_shrink_potions): + def new_game(self, rows, columns, n_apples, n_ice_creams, + n_shrink_potions, n_walls): self.game_ticks = 0 self.game_id = self.random.randint(0, sys.maxint) @@ -65,6 +68,7 @@ class Engine(object): self.add_items(common.APPLE, n_apples) self.add_items(common.ICE_CREAM, n_ice_creams) self.add_items(common.SHRINK_POTION, n_shrink_potions) + self.add_items(common.WALL, n_walls) def add_bot(self, bot, team=None, colour=None): """ diff --git a/snakegame/images/wall.png b/snakegame/images/wall.png Binary files differnew file mode 100644 index 0000000..c211d78 --- /dev/null +++ b/snakegame/images/wall.png diff --git a/snakegame/viewers/pygame.py b/snakegame/viewers/pygame.py index 3f32da1..7a6f8f1 100644 --- a/snakegame/viewers/pygame.py +++ b/snakegame/viewers/pygame.py @@ -62,7 +62,8 @@ class Viewer(object): self.items = { common.APPLE : 'images/apple.png', common.ICE_CREAM : 'images/icecream.png', - common.SHRINK_POTION : 'images/shrinkpotion.png' + common.SHRINK_POTION : 'images/shrinkpotion.png', + common.WALL : 'images/wall.png', } for item in self.items: self.items[item] = load_image(self.items[item], xscale, yscale) diff --git a/snakegame/viewers/pyglet.py b/snakegame/viewers/pyglet.py index f1a5f88..9e0da21 100644 --- a/snakegame/viewers/pyglet.py +++ b/snakegame/viewers/pyglet.py @@ -62,7 +62,8 @@ class Viewer(pyglet.window.Window): self.images = { common.APPLE : 'images/apple.png', common.ICE_CREAM : 'images/icecream.png', - common.SHRINK_POTION : 'images/shrinkpotion.png' + common.SHRINK_POTION : 'images/shrinkpotion.png', + common.WALL : 'images/wall.png', } for item, location in self.images.items(): |