home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.programming
- Path: sparky!uunet!cs.utexas.edu!torn!cunews!dfs
- From: dfs@doe.carleton.ca (David F. Skoll)
- Subject: Re: MAZE
- Message-ID: <dfs.711915117@ro>
- Sender: news@cunews.carleton.ca (News Administrator)
- Organization: Dept. of Electronics, Carleton University
- References: <1992Jul23.145751.29068@wuecl.wustl.edu>
- Date: Thu, 23 Jul 1992 18:11:57 GMT
- Lines: 45
-
- In <1992Jul23.145751.29068@wuecl.wustl.edu> ppc1@cec2.wustl.edu (Peter
- Pui Tak Chiu) writes:
-
- >I am trying to write a 3D maze in which the player can move around as if
- >he/she is "inside" the maze. (something like the adventure game ULTIMA
- >when you are inside a dungeon...)
-
- >I wrote a version but it is extremely slow. First I transform the 2D maze
- >into 3D coordinates. Then for every move, I redraw the maze with appropriate
- >transformation, rotations and hidden surface eliminations... and as you can
- >tell it takes a lot of TIME!!!
-
- I assume you mean that the maze itself is 2-D, but you want to see "walls"
- as if you're inside the maze.
-
- One technique with which I had great success divided the maze into
- grids. A person occupied a particular grid point. Then, I did this:
-
- current-grid = player's grid
- size = full-screen
- blocked = FALSE
- shrink-factor = 1.2
-
- while (not blocked)
- draw-view(size, current-grid, player-direction)
- size = size / shrink-factor
- {move one grid in the direction that the player is facing.}
- current-grid = current-grid -> player-direction
- {If you can't move in that direction, stop}
- if (not current-grid) blocked = TRUE
- endwhile
-
- The draw-view function simply draws the view of the current cell as
- seen from the player's position, leaving a "hole" for the next cell along,
- unless the current cell is blocked by a wall. In that case, draw the wall.
-
- The basic idea is to draw a single cell's view, shrink the size down, and keep
- drawing successive cells until a wall blocks the view. You can also terminate
- after a fixed number of cells to limit the distance a player can see.
-
- I hope that's clear! I implemented this in BASIC on a TRS-80 Color
- Computer :-) many moons ago, and it ran very quickly.
-
- --
- David F. Skoll
-