I'm making an rpg game. I have a Grid class which takes a char to create tiles. The way I'm currently doing collision detection is by creating a Player and assigning it the grid it should be created in.
However, (because it seems to be the easiest way to do things) I want to be able to have a class that has an array of Grids that only load the map information when neccessary (i.e. when the player is close enough to the next grid).
My past implementation was when i had a Grid. However, this causes problems when I want to walk off my current grid and the game gives me a ArrayIndexOutOfBoundsException. My main concern is this: I want to be able to design a system that loads information as I need it.
My questions are: How should I go about doing this? Is this the most efficient way to design things? If I have to redesign something things, I'm willing to, as I'm in the early stages of game design.