Advertisement
itak365

escapemaze.py

Mar 21st, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. from random import*
  2. def escapemaze():
  3. choose=pickAFile()
  4. maze=makePicture(choose)
  5. show(maze)
  6. h=getHeight(maze)
  7. w=getWidth(maze)
  8. y=h/2
  9. x=w/2
  10. boom=0
  11. beamedUp=0
  12. outside=0
  13. robot = getPixelAt(maze, x, y)
  14. setColor(robot, magenta)
  15. repaint(maze)
  16. while (outside == 0 and beamedUp == 0 and boom == 0):
  17. xOld=x
  18. yOld=y
  19. x = x + randrange(-5, 6)
  20. y = y + randrange(-5, 6)
  21. robot = getPixelAt(maze, x, y)
  22. repaint(maze)
  23. if x < 0 or x >= w or y < 0 or y >= h:
  24. outside= 1
  25. else:
  26. color= getColor(robot)
  27. if color== black:
  28. x=xOld
  29. y=yOld
  30. elif color== red:
  31. boom=1
  32. elif color== blue:
  33. beamedUp=1
  34. addLine(maze, xOld, yOld, x, y, magenta)
  35. repaint(maze)
  36. if outside==1 or beamedUp==1:
  37. showInformation("YOU ARE SAFE NOW!")
  38. else:
  39. showInformation("BOOM!")
  40. showInformation("Game Over.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement