[Question] Best way to make maps infinite?

Hi there JGO,

as some of you may know I am programming a small multiplayer RPG game. I want to make my maps some sort of infinite. I don’t know how it’s possible on the way I am using tiles.

How I use tiles:

tiles = new byte[width * height]; //Creating all tiles
this.tiles[x + y * width] = newTile.getId(); //Altering tiles

So basically my tiles are stored in rows, and with my current system I don’t know how to add another chunck to be able to still alter te right tiles and an important feature: how to have negative x’s and y’s… If you have anything that could/would help me then just say it. I do not want the codes. I want to learn by solving my own problems, I only need a step in the right direction

-RoseSlayer``

http://www.java-gaming.org/index.php?topic=23484.0

Thanks, next time I probably should search more times then 1 -,-

Now I made saveFiles and loadFiles I add this feature.
The only part I know how to do now is adding eachChunk. I don’t know how to draw them…

Example on creating chunks:

        createChunk(cx >> 4, cy >> 4); //It's an example and CX aren't real variables yet.
    private void createChunk(int cx, int cy){
		try {
			FileOutputStream saveFile = new FileOutputStream(levelDirectory + "/chunk[" + cx + "," + cy + "].dat");
			ObjectOutputStream save = new ObjectOutputStream(saveFile);
			/*SAVING THINGS, Don't know how to do yet.*/
			save.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }

With this way it will easily make 16*16 chunks. But I don’t know how to handle and save the Tiles. I am drawing them right now with:

x + y * width

.

If you guys could help me through this it would be perfect!
-RoseSlayer