Map data only returning 0

BlitzPlus Forums/BlitzPlus Beginners Area/Map data only returning 0

OzBlitzManic(Posted 2005) [#1]
Hi all,
I am attempting to make a wireframe maze game - you know the type, the really early days of games early Ultima and Wizardry type... I (think I) have set everything up (its still in its very early days!) but when I test the maze data, all I seem to return are Zeros. So it doesnt appear to be reading the maze data correctly. This is my 1st crack at getting into data statements, so I still dont fully understand how they work, but with Krylars book and a bit of blood sweat and tears, I'm hoping to crack the nut in the next couple of days. Have a look at the code and see if you can see the (probably really simple) error I have made...




CS_TBL(Posted 2005) [#2]
First of all, put the ReadMaze call before the mainloop. No need to read all that data again and again each time..

Next:

in your mainloop you do a nested FOR to print the maze, add '-1' to the forloops, as you did in the ReadMaze function.


Now I'll try to rest/run it in blitz :P :P


CS_TBL(Posted 2005) [#3]
also: while DIM'ing, if you need an array of 10 elements, then dim bla(9) will do, so in this case: dim maze(Map_Length-1,Map_Height-1)

another detail:

Read a ; get the map data and store into value
maze(x,y) = a

could ofcourse be:

Read maze(x,y)

..saves the creation/use of 'a' :P


CS_TBL(Posted 2005) [#4]
ahyes ^_^

Map_Height and Map_Length aren't globals!

So in the readmaze function the for's go from 0 to -1 :P

Note that a DIM'ed variable is always a global (much to my regrets..)


CS_TBL(Posted 2005) [#5]
While we're on it, I'd advice to drop the word map_'Length' here and use map_'Width' instead.. it's a peanuts-remark, I know, but everything is always width/height.. like the Rect command for example..

Another one,

the DrawBox function.. perhaps in the future you come straight from another function that does some drawing.. what if that function changes color? Always add a color r,g,b or color ,,rgb command when you're drawing!


Floyd(Posted 2005) [#6]
Also, I think you have confused rows and columns.

The value read as maze(x,y) should be maze(y,x).


CS_TBL(Posted 2005) [#7]
As a bonus, here's your code, lightly modified by me

And as a bonus I added a mini-mapviewer :P 'ave fun~




OzBlitzManic(Posted 2005) [#8]
Wow!. That is excellent. Thank's so much for this. I will now go thru the code and see how you did the minimap. Its awesome (well, for my current level of expertise :-) ). I guess I have a bit further to go, but every journey begins with the first step.

Again thanks heaps for the help.