summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--snakegame/engine.py10
-rw-r--r--snakegame/images/wall.pngbin0 -> 1025 bytes
-rw-r--r--snakegame/viewers/pygame.py3
-rw-r--r--snakegame/viewers/pyglet.py3
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
new file mode 100644
index 0000000..c211d78
--- /dev/null
+++ b/snakegame/images/wall.png
Binary files differ
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():