home *** CD-ROM | disk | FTP | other *** search
- /*
- ** fillmaze.c Copyright 1991 Kent Paul Dolan,
- ** Mountain View, CA, USA 94039-0755
- **
- ** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
- ** May be freely used or modified in any non-commercial work. Copyrighted
- ** only to prevent patenting by someone else.
- */
-
- #include <stdio.h>
- #include "townmaze.h"
- #include "townproto.h"
-
- #ifdef __STDC__
- void fillmaze()
- #else
- int fillmaze()
- #endif
- {
- int i, j;
-
- #if PROGRESS
- fprintf(stderr,"Fill maze ");
- #endif
-
- /*
- ** Fill maze with "wall" characters and "blank" characters,
- ** so that entire maze starts out as doorless rooms with walls
- ** between.
- */
-
- for (i = 0; i < mazeheight; i++)
- for (j = 0; j < mazewidth; j++)
- switch (((i%2)<<1) + (j%2))
- {
- case 0:
- cmaze[i][j] = WALL;
- break;
- case 1:
- cmaze[i][j] = WALL;
- break;
- case 2:
- cmaze[i][j] = WALL;
- break;
- case 3:
- cmaze[i][j] = BLANK;
- break;
- default:
- fprintf(stderr,"failure in maze fill section\n");
- freespace();
- exit(1);
- }
- /*
- ** The corner cells are too hard to use, so nuke them in the drawing.
- */
-
- cmaze[1][1] = WALL;
- cmaze[1][mazewidth - 2] = WALL;
- cmaze[mazeheight - 2][1] = WALL;
- cmaze[mazeheight -2][mazewidth - 2] = WALL;
-
- return;
- }
-