Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import*
- def escapemaze():
- choose=pickAFile()
- maze=makePicture(choose)
- show(maze)
- h=getHeight(maze)
- w=getWidth(maze)
- y=h/2
- x=w/2
- boom=0
- beamedUp=0
- outside=0
- robot = getPixelAt(maze, x, y)
- setColor(robot, magenta)
- repaint(maze)
- while (outside == 0 and beamedUp == 0 and boom == 0):
- xOld=x
- yOld=y
- x = x + randrange(-5, 6)
- y = y + randrange(-5, 6)
- robot = getPixelAt(maze, x, y)
- repaint(maze)
- if x < 0 or x >= w or y < 0 or y >= h:
- outside= 1
- else:
- color= getColor(robot)
- if color== black:
- x=xOld
- y=yOld
- elif color== red:
- boom=1
- elif color== blue:
- beamedUp=1
- addLine(maze, xOld, yOld, x, y, magenta)
- repaint(maze)
- if outside==1 or beamedUp==1:
- showInformation("YOU ARE SAFE NOW!")
- else:
- showInformation("BOOM!")
- showInformation("Game Over.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement