0

I'm doing a tutorial on a basic 2D tower defense game, and we're basically trying to fill a window with a bunch of tiles, but I get an ArrayOurOfBoundsException here, and I don't get why!

    map = new Tile[20][12];
    for (int i=0; i < map.length; i++) {
        for (int j=0; i < map[i].length; j++) {
            map[i][j] = new Tile(i*64, j*64, 64, 64, TileType.Grass);
        }
    }
1
  • 1
    You should do some debugging. Commented Mar 6, 2016 at 23:40

1 Answer 1

4
for (int j=0; i < map[i].length; j++)
//            ↑

That's an i, not a j.

So maybe you need to use a different font, or use a different letter for your inner loops.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.