So i'm trying to make a Single maze (No generators) In Java, and I've hit a roadblock. the current code i have will make a maze, and make a jframe, but it won't color it... is there a way to make the coloring work??
import java.awt.*;
import javax.swing.*;
import java.lang.*;
public class ayy{
public static void main(String [] args){
JFrame frame = new JFrame("Maze");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setSize(1000,1000);
frame.setVisible(true);
int width = 1;
int height = 1;
int [][] map= {
{0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,},
{2,1,1,1,0,0,0,0,0,0,},
{0,0,0,1,0,0,0,1,1,2,},
{0,0,0,1,0,0,0,1,0,0,},
{0,0,0,1,0,0,0,1,0,0,},
{0,0,0,1,1,1,1,1,0,0,},
{0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,}
};
for(int i=0;i<map.length;i++){
for(int j=0;j<map.length;j++){
switch(map[i][j]){
case 0:
class rectangle{
public void paint(Graphics g){
g.drawRect(1,1,1,1);
g.setColor(Color.red);
}
}
break;
case 1:
class rectangle2{
public void paint(Graphics g){
g.drawRect(1,1,1,1);
g.setColor(Color.yellow);
}
} break;
case 2:
class rectangle3{
public void paint(Graphics g){
g.drawRect(1,1,1,1);
g.setColor(Color.blue);
}
} break;
}
}
}
}
}
Any help will do Thanks!