Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kitson <msk5293@rit.edu>2010-11-09 15:35:01 (GMT)
committer Michael Kitson <msk5293@rit.edu>2010-11-09 15:35:01 (GMT)
commit5cb09ccd394a4685f8bc7c5ef13650742be4d138 (patch)
tree277ab2f63ca072cf247bb9b84c60bc97c6365582
parent3875ca1fb155c81e050aeca416601fed7fb76e94 (diff)
Now uses the new maze images when drawing the maze.
-rw-r--r--dev/pacmath.activity/images/25_lines_lr.gifbin0 -> 94 bytes
-rw-r--r--dev/pacmath.activity/images/25_lines_ud.gifbin0 -> 120 bytes
-rw-r--r--dev/pacmath.activity/images/50_left.gifbin0 -> 97 bytes
-rw-r--r--dev/pacmath.activity/images/50_right.gifbin0 -> 97 bytes
-rw-r--r--dev/pacmath.activity/maze.py7
-rw-r--r--dev/pacmath.activity/mazeSetup.py62
6 files changed, 67 insertions, 2 deletions
diff --git a/dev/pacmath.activity/images/25_lines_lr.gif b/dev/pacmath.activity/images/25_lines_lr.gif
new file mode 100644
index 0000000..382a2ed
--- /dev/null
+++ b/dev/pacmath.activity/images/25_lines_lr.gif
Binary files differ
diff --git a/dev/pacmath.activity/images/25_lines_ud.gif b/dev/pacmath.activity/images/25_lines_ud.gif
new file mode 100644
index 0000000..6d9f064
--- /dev/null
+++ b/dev/pacmath.activity/images/25_lines_ud.gif
Binary files differ
diff --git a/dev/pacmath.activity/images/50_left.gif b/dev/pacmath.activity/images/50_left.gif
new file mode 100644
index 0000000..3e7c070
--- /dev/null
+++ b/dev/pacmath.activity/images/50_left.gif
Binary files differ
diff --git a/dev/pacmath.activity/images/50_right.gif b/dev/pacmath.activity/images/50_right.gif
new file mode 100644
index 0000000..592865f
--- /dev/null
+++ b/dev/pacmath.activity/images/50_right.gif
Binary files differ
diff --git a/dev/pacmath.activity/maze.py b/dev/pacmath.activity/maze.py
index 99d7182..c9b434a 100644
--- a/dev/pacmath.activity/maze.py
+++ b/dev/pacmath.activity/maze.py
@@ -13,7 +13,7 @@ grid = []
class Maze:
"""
- @var EMPTY: An empty space in the maze where a regular pelet would be
+ @var EMPTY: An empty space in the maze where a regular pellet would be
@var SOLID: A wall representation in the maze
@var OFFL: A space off limits to pacmath character
@var PELLET: Where you could move and collect a regular pellet
@@ -102,3 +102,8 @@ class Maze:
#simply returns the grid (or map)
return grid
+ def getPoint(self, x, y):
+ if x < 0 or y < 0 or x >= self.width or y >= self.height:
+ return self.SOLID
+ else:
+ return self.map[x][y]
diff --git a/dev/pacmath.activity/mazeSetup.py b/dev/pacmath.activity/mazeSetup.py
index ee29fe2..94d5c90 100644
--- a/dev/pacmath.activity/mazeSetup.py
+++ b/dev/pacmath.activity/mazeSetup.py
@@ -59,7 +59,11 @@ class mazeSetup:
pygame.draw.rect(screen, (0, 0, 0), rect, 0)
elif tile == self.maze.SOLID:
#1
- pygame.draw.rect(screen, (255,255,255) , rect, 0)
+ image = self.getWallImage(x,y)
+ if image == False:
+ pygame.draw.rect(screen, (0,0,0) , rect, 0)
+ else:
+ screen.blit( image, rect )
elif tile == self.maze.OFFL:
#2
pygame.draw.rect(screen, (0,0,0), rect, 0)
@@ -97,3 +101,59 @@ class mazeSetup:
for b in range(0, MAZE_SIZE):
self.drawPoint(screen, a, b)
+
+ def getWallImage(self, x, y):
+ """
+ Choses the correct image for wall positions based on the surrounding
+ plots
+ @param x: x coordinate
+ @param y: y coordinate
+ @return a converted image
+ """
+ file = 'EMPTY'
+
+ sides = [ self.maze.getPoint(x,y-1) == self.maze.SOLID, # top
+ self.maze.getPoint(x+1,y) == self.maze.SOLID, # right
+ self.maze.getPoint(x,y+1) == self.maze.SOLID, # bottom
+ self.maze.getPoint(x-1,y) == self.maze.SOLID ] # left
+
+ if sides == [0,0,0,0]: # draw box
+ print "We need a box!"
+ elif sides == [0,0,0,1]: # draw 180 right
+ file = './images/25_c_r.gif'
+ elif sides == [0,0,1,0]: # draw 180 up
+ file = './images/25_c_u.gif'
+ elif sides == [0,0,1,1]: # draw 90 top right
+ file = './images/50_c_rt.gif'
+ elif sides == [0,1,0,0]: # draw 180 left
+ file = './images/25_c_l.gif'
+ elif sides == [0,1,0,1]: # draw parallel left right
+ file = './images/25_lines_lr.gif'
+ elif sides == [0,1,1,0]: # draw 90 top left
+ file = './images/50_c_lt.gif'
+ elif sides == [0,1,1,1]: # draw line top
+ file = './images/50_top.gif'
+ elif sides == [1,0,0,0]: # draw 180 bottom
+ file = './images/25_c_d.gif'
+ elif sides == [1,0,0,1]: # draw 90 bottom right
+ file = './images/50_c_rb.gif'
+ elif sides == [1,0,1,0]: # draw parallel top bottom
+ file = './images/25_lines_ud.gif'
+ elif sides == [1,0,1,1]: # draw line right
+ file = './images/50_right.gif'
+ elif sides == [1,1,0,0]: # draw 90 bottom left
+ file = './images/50_c_lb.gif'
+ elif sides == [1,1,0,1]: # draw line bottom
+ file = './images/50_bottom.gif'
+ elif sides == [1,1,1,0]: # draw line left
+ file = './images/50_left.gif'
+ elif sides == [1,1,1,1]: # draw empty
+ file = 'EMPTY'
+
+ else:
+ print "MAZE FAIL"
+
+ if not file == 'EMPTY':
+ return pygame.image.load(file).convert()
+ else:
+ return False