home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d171 / maze.lha / Maze / README < prev    next >
Text File  |  1988-11-22  |  2KB  |  62 lines

  1. [ Editors note -- I made some changes to make Aztec accept this program.
  2.   The changes I made are marked with "PDS(n)":
  3.  
  4.       PDS(1)    Expression was too complex.
  5.     PDS(2,3)  Aztec requires a statement after a label. This is legit
  6.         according to K&R, by the way.
  7.  
  8.   Peter da Silva, 31 July 1988 ]
  9.  
  10. This is a small, everything but useful routine to create mazes. The
  11. resulting maze is unique, i.e. there is only one way from one point of the
  12. maze to another. The logic is quite simple: first a border of passages is
  13. drawn around the maze (just to prevent your 8 meg. memory expansion being
  14. mapped out), then a random starting point is selected. The maze is divided
  15. into 2*2 squares. From the current position we pick up a  random direction
  16. and draw a line (well, 2 points actually) to the next 2*2 square, if it is
  17. free (i.e. if there is no passage, only walls). If it is not, we check the
  18. remaining directions. If everything fails ( we got into a dead end), we
  19. move one step back and check if we can continue from there. If we reach our
  20. starting point while moving back, the maze is finished.
  21.  
  22. Syntax:
  23.  maze( width, height, area)
  24.  
  25.  short width,height
  26.  char *area
  27.  
  28.  width  = width  of your maze.
  29.  height = height of your maze
  30.  *area  = pointer to the buffer where the maze should be generated.
  31.           The buffer should be clear,i.e zeroed.
  32.  
  33. Normally the program assumes your buffer being a matrix of [width][height]
  34. chars. In return you will get your buffer filled with 1's (passage) and 0's
  35. (walls).
  36. If you define 'bitmap' (#define bitmap at the start of your program) the
  37. result will be an area of bits. Bit clear means passage,bit set means wall.
  38.  
  39. To make life easy, there are two macros defined:
  40.  
  41. One to check if a x,y position is passage or wall:
  42. MAZETEST (xpos,ypos,mazewidth,pointer to buffer)
  43. result: 0 if passage, anything else if wall.
  44.  
  45. Another to set a position to passage:
  46. MAZESET (xpos,ypos,mazewidth,pointer to buffer)
  47.  
  48. Included are two demo programs: SpeedDemo - Draws a maze into a
  49. low resolution screen, press any key to get a new one, and 3Ddemo, a simple
  50. 3D maze featuring: No double buffering, no smooth animation and no sound.
  51. Use the arrow keys on the num-pad to move.
  52.  
  53. If you use this code in your own program, I would be pleased if you send me
  54. a copy.
  55.  
  56. Happy wandering (or wondering)
  57. Werner Gunther
  58. G35@DHDURZ2.BITNET
  59.  
  60. P.S. This code is freely distributable, deleteable etc.,etc...
  61.  
  62.