I want to create a simple grid in Java as a map editor working with tiles. In my render method I've put this
public void render(Graphics g){
renderGrid(g,96,64);
}
private void renderGrid(Graphics g,int width, int height) {
g.setColor(Color.white);
for (int y = 0; y < height; y += 32){
for (int x = 0;x<width; x+= 32){
g.drawRect(x, y, x+32, y+32);
System.out.println("x =" + x + " y= " + y + " width= " + (x + 32 - x) + " height=" + (y + 32 - y)+ " column No= " + x/32 + " row No= " + y / 32);
}
}
}
But when I start the program, it gives me this:
Here's the debug message
x =0 y= 0 width= 32 height=32 column No= 0 row No= 0
x =32 y= 0 width= 32 height=32 column No= 1 row No= 0
x =64 y= 0 width= 32 height=32 column No= 2 row No= 0
x =0 y= 32 width= 32 height=32 column No= 0 row No= 1
x =32 y= 32 width= 32 height=32 column No= 1 row No= 1
x =64 y= 32 width= 32 height=32 column No= 2 row No= 1
Any suggestion? Why aren't the cells square?