I need to import a as ascii map into my Java game to set the world you will be able to move around in.
For example.
###################
#.................#
#......G........E.#
#.................#
#..E..............#
#..........G......#
#.................#
#.................#
###################
Where the # are walls G is gold E is exit and the . are blanks spaces to move around on. I currently have this in a .txt file. I need to create a method to import the map into a 2D char[][]
array.
How would this work. Whats the best way to do this. I haven't done any work with 2D arrays yet so this is new to me.
Thanks, Ciaran.
Just have 2 Scanners?
public char[][] map = new char[9][19];
The map will be created. It is up to you to add in functionality for Gold, exits and walls. I suggest using enums or an abstract Tile class.
Hope this healped.
Jarod.
Haven't tested it but this should do the trick: