I cannot seem to work out how to get terrain to load dynamically so I could load say a whole world from heightmap data as in world01_01.bmp up to say world99_99.bmp dynamically it's confusing as hell can someone help with some sample code on loading a set of heightmaps once you reach the edge of another
Here is a diagram of what I am trying to achieve
Code: Select all
[x] = loaded map tile(generated from heightmap)
[o] = not loaded map tile/unloaded map tile(to be generated from heightmap)
[p] = map-tile player is on
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][x][x][x][o][o][o][o][o]
[o][o][o][o][x][p][x][o][o][o][o][o]
[o][o][o][o][x][x][x][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
[o][o][o][o][o][o][o][o][o][o][o][o]
the only thing I can think of at the moment is loading all the data into an array for every map tile using the in-built culling and hoping for the best, alternatively assuming the map goes from 01_01->99_99 the loaded tiles would be calculated relative to the players position
Code: Select all
//assuming players x & y co-ords are set
//load tiles (assuming if they are already loaded to leave them be)
//top row
loadtile(player.x-1,player.y-1);
loadtile(player.x,player.y-1);
loadtile(player.x+1,player.y-1);
//middle row
loadtile(player.x-1,player.y);
loadtile(player.x,player.y);
loadtile(player.x+1,player.y);
//bottom row
loadtile(player.x-1,player.y+1);
loadtile(player.x,player.y+1);
loadtile(player.x+1,player.y+1);