home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / programm / 2082 < prev    next >
Encoding:
Text File  |  1992-07-23  |  2.1 KB  |  57 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!cs.utexas.edu!torn!cunews!dfs
  3. From: dfs@doe.carleton.ca (David F. Skoll)
  4. Subject: Re: MAZE
  5. Message-ID: <dfs.711915117@ro>
  6. Sender: news@cunews.carleton.ca (News Administrator)
  7. Organization: Dept. of Electronics, Carleton University
  8. References: <1992Jul23.145751.29068@wuecl.wustl.edu>
  9. Date: Thu, 23 Jul 1992 18:11:57 GMT
  10. Lines: 45
  11.  
  12. In <1992Jul23.145751.29068@wuecl.wustl.edu> ppc1@cec2.wustl.edu (Peter
  13. Pui Tak Chiu) writes:
  14.  
  15. >I am trying to write a 3D maze in which the player can move around as if
  16. >he/she is "inside" the maze.  (something like the adventure game ULTIMA
  17. >when you are inside a dungeon...)
  18.  
  19. >I wrote a version but it is extremely slow.  First I transform the 2D maze
  20. >into 3D coordinates.  Then for every move, I redraw the maze with appropriate
  21. >transformation, rotations and hidden surface eliminations...  and as you can
  22. >tell it takes a lot of TIME!!!
  23.  
  24. I assume you mean that the maze itself is 2-D, but you want to see "walls"
  25. as if you're inside the maze.
  26.  
  27. One technique with which I had great success divided the maze into
  28. grids.  A person occupied a particular grid point.  Then, I did this:
  29.  
  30. current-grid = player's grid
  31. size = full-screen
  32. blocked = FALSE
  33. shrink-factor = 1.2
  34.  
  35. while (not blocked)
  36.    draw-view(size, current-grid, player-direction)
  37.    size = size / shrink-factor
  38.    {move one grid in the direction that the player is facing.}
  39.    current-grid = current-grid -> player-direction
  40.    {If you can't move in that direction, stop}
  41.    if (not current-grid) blocked = TRUE
  42. endwhile
  43.  
  44. The draw-view function simply draws the view of the current cell as
  45. seen from the player's position, leaving a "hole" for the next cell along,
  46. unless the current cell is blocked by a wall.  In that case, draw the wall.
  47.  
  48. The basic idea is to draw a single cell's view, shrink the size down, and keep
  49. drawing successive cells until a wall blocks the view.  You can also terminate
  50. after a fixed number of cells to limit the distance a player can see.
  51.  
  52. I hope that's clear!  I implemented this in BASIC on a TRS-80 Color
  53. Computer :-) many moons ago, and it ran very quickly.
  54.  
  55. --
  56. David F. Skoll
  57.