Number grid map?

Blitz3D Forums/Blitz3D Beginners Area/Number grid map?

Kiyoshi(Posted 2011) [#1]
Hi people. A while back, I recall playing an "escape the maze" type game. This was a basic game, nothing really special. But what I found interesting was that the mazes were created using a grid of numbers read from a .txt file, looks like this:

11111111
10100011
10001001
10111101
10120001
11111111

0=Empty space, 1=Wall, and 2=Maze exit. I'm wondering, could you do this with Blitz3d, and if so, how is it done?

Thanks!
Zaraki


Matty(Posted 2011) [#2]
To do this you would use the file commands (readfile(), readline(), ) and also the string commands (mid$()).

eg

Something like this should get you started...


infile=readfile("your text file here")
if infile<>0 then 
	while(not(eof(infile)))
		myline$=readline(infile)
		if len(myline)>0 then 
			y=y+1
			for x=1 to len(myline)
				cellvalue=mid(myline,x,1)
				;then simply store the cellvalue, x and y values in an array 
			next
		endif 
	wend 
	closefile infile
else
	runtimeerror("file not found")
endif 



PowerPC603(Posted 2011) [#3]
Once I created such a testing game, which uses a similar format.
http://users.telenet.be/vge/downloads/MazePack.zip

Just extract the file somewhere and run the 3 exe's after each other:
- MazeGenerator.exe
- MazeConverter.exe
- Maze3D.exe

The first program (MazeGenerator) creates a bitmap for a randomized maze and saves the bitmap as Maze.bmp.

The second program (MazeConverter) reads this bitmap, analyses it and creates the file Maze.dat.
This is a simply textfile which you can open in Notepad.
Every corridor-type has a different code for it.
A straight corridor has a different value than a corner.

The final program (Maze3D) reads this Maze.dat and creates a 3D version of the maze for you to walk through.
It's not optimized or anything, it was only to have some fun walking around a maze instead of solving it on paper.

The entire source-code is supplied as well in the subfolders.