Advertisement
itak365

escapemaze.py

Mar 21st, 2014
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 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. robot=getPixel(maze,x,y)
  11. setColor(robot, magenta)
  12. repaint(maze)
  13. boom=0
  14. beamedUp=0
  15. outside=0
  16. while (outside == 0 and beamedUp == 0 and boom == 0):
  17. xOld=x
  18. yOld=y
  19. robot = getPixel(maze, x, y)
  20. setColor(robot, magenta)
  21. repaint(maze)
  22. x = x + randrange(-5, 6)
  23. y = y + randrange(-5, 6)
  24. if x < 0 or x >= w or y < 0 or y >= h:
  25. outside == 1
  26. else:
  27. color= getColor(robot,x,y)
  28. if color= black:
  29. x=xOld
  30. y=yOld
  31. elif color= red:
  32. boom=1
  33. elif color= blue:
  34. beamedup=1
  35. addLine(maze, xOld, yOld, x, y, magenta)
  36. repaint(maze)
  37. if outside==1 or beamedUp==1:
  38. showInformation("YOU ARE SAFE NOW!")
  39. else:
  40. showInformation("BOOM!")
  41. showInformation("Game Over.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement