Re: Help with coding a map in bgt
I like string arrays, because then it's more like drawing. This only works if you have a good spatial / tactile / visual imagination (braille helps, and as a bonus, you don't even need to be good at reading it).
But there's too much processing involved in saving a map as a string array directly. Especially given that BGT doesn't seem to distinguish between single-character strings and individual characters (the latter would be fast; the former is slow).
So you could just draw a map like so:
string[] map={
"----------",
"- -",
"- rrr -",
"- r r-",
"- -",
"- r r -",
"- r -",
"- r r -",
"- -",
"----------"
};
Where hyph
ens are walls, 'r's are rocks, and spaces are clear.
You can get the value at an individual tile in BGT like so:
string tile_to_check=map[row][column];
To be quicker, you might want to do this:
if(map[target_y][target_x]=="-") do_not_move();
else if(map[target_y][target_x]=="r") hit_rock();
else move();
For some reason, though, this method feels wrong by itself. Maybe it's that strings are generally bulky; this wouldn't be a problem in, say, C, but in most higher-level languages, they are both slower and larger.
(I usually just write a function that loops through a string array and converts it to an int array, if I'm using this method.)
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector