Hi everyone,
I'm pretty new to
Java as well as these forums and I was hoping someone could point me in the right direction with my current project. I'm supposed to be creating a maze from a text file. The text file consists of an arrangement of 4 characters: *, ' ' (open space), F, and S. I successfully got my program to read the file line by line. I know this because it prints the file out to the console when I use print statements. My big problem is getting it to display on my JPanel. Each character in the file is supposed to be replaced with a 12 x 12 colored rectangle. This is what each character in the text file is supposed to represent:
* - A wall, will be Black
space - open space, will be white
S - Start point, will be Cyan
F - Finish point, will be Red
I have an array of colors which looks like this (there's 7 colors in here because I need to add more things later):
I've also declared the following variables:
Here's what my file reader looks like:
And here's what my paint method looks like:
Every time I run my program, it immediately shows a large black square, then when I load my text file nothing happens. So I'm having a lot of trouble getting elements in the text file to display as the colored bricks I need. Can anyone see what I'm doing wrong? Thank you so much for anyone's time!