i need help with simple tile map. i have 2d array as map.
so i want to replce numbers in array with rect's.
0 = green rect
1 = red rect
2 = black rect
and i want it so that the all tile are same size.
when i run this it the drawing on screen doesnt match the drawing in array and it output random blocks. the code look fine to me but iam sure i am missing some thing.
import java.awt.Color;
import java.awt.Graphics;
public class levels
{
int level01[][] = { {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
{2,1,2,2,2,2,2,2,2,2,2,2,2,2,2},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}};
public levels()
{
}
//@Override
public void paint(Graphics g)
{
for(int y = 0; y < level01.length; y++) //rows
{
for(int x = 0; x < level01[y].length; x++) //cols
{
if(level01[y][x] == 0)
{
g.setColor(Color.green);
g.drawRect(x, y, 200, 200);
}
if(level01[y][x] == 1)
{
g.setColor(Color.red);
g.drawRect(x, y, 200, 200);
}
if(level01[y][x] == 2)
{
g.setColor(Color.black);
g.drawRect(x, , 200, 200);
}
}
}//end of main for loop
//super.paint(g);
}//end of paint method
}//end of level01 class