by EvanBlack » Sat Oct 08, 2011 8:00 pm
Well, I think using a range MAXSIZE's would be best, that way I can limit errors on map generation. I don't want someone trying to generate a map that is larger that the resources on their computer. But I may just use both, that way if the user creates a small map, I can allocate resources and save hard drive space. I don't want to have a map 10x10 stored in a array sized for 100,000,000 tiles.
Using a range of MAXSIZE constants would be best, then I can check the size of there map in a case/switch statement and allocate space accordingly.
I could, also, have a beginning menu that lets you choose the size of the storage array that you want to use, then attempt to allocate that space in memory.
But also have a dynamic allocation system on hand if say, the user chooses Array of 100 Million Tiles, but only uses 500 Thousand. I could then free the extra allocated space in the array that was originally chosen then attempt to store the map. On error, I just tell the user that space could not be allocated. IF error on map save, tell user map was not saved with reason.
For now I have a map generation limit of 10,000 tiles. But that is just because I am going to try to create a tile handler that creates and destroys tiles within range of the new. So that way I don't have to use activation regions and I don't get a heavy map load and can generate larger maps. (practically unlimited scale)
Then I am going to have the game load part of each map as sections of a larger map. So I can use like 30 map editor files to load 1 game map. When the game will be released as an EXE. I will combined all the map editor files into a single world map file (maybe, I'd rather store the maps outside the exe for later editing, and user generated maps.), then the game will load portions of each file as needed.
Map Linking will be done based on nodes. If I have the exit of one map at node x,y, then the next map will begin at x,y and the entrance will be linked perfectly.
The reason I want to use 3D array is for storage and easier access. But I may just use several 2D arrays, depending on which has a faster access time. Or which is better for the game. Or both.
For the 3D array design:
Map[x][y][1] = Map Tiles
Map[x][y][2] = Objects (such as trees, chests, waypoints, ect.)
Map[x][y][3] = Creatures (such as critters, enemies, Bosses)
Possible 2D arrays design:
Map[x][y] = Map Tiles
int Objects[NumberOfVariables][NumberOfObjects];
Objects[1][ObjectID] = Object Type (such as: 0:Tree, 1:Chest, 2:Waypoint, ect..)
Objects[2][ObjectID] = Object X position
Objects[3][ObjectID] = Object Y position
Objects[#][ObjectID] = Objects Other Variables (such as: isDestructable, Health, Hardness, ect.
int Creatures[NumberOfVariables][NumberOfCreatures];
Creatures[1][CreatureID] = Creature's Type (such as: 0:Wolf, 1:Man Eater, 2:Acid Jelly, ect)
Creatures[2][CreatureID] = Creature's X position
Creatures[3][CreatureID] = Creature's Y position
Creatures[#][CreatureID] = Creature's Other Variables (such as: isDestructable, Health, Hardness, ect.[/code]
Then the game will break the 3D array into the 2D arrays above. Unless, I don't use the 3D array Idea.
The one issue I have with using the 3D array is that it wastes space. While my 2D arrays use minimum space and allow more variables. I might just scrap the 3D idea and only use 2D arrays. Just multiple like this.
My idea for creatings tiles within range, is pushing and poping tiles on a stack. As some tiles come within range and other tiles leave range, remove old tiles from stack and put the new tiles onto the stack, and sort them by range of player. Each tile has its own ID so knowing which tile to create and destroy will be easy. The stack will be a 2D array like map, but will be limited to range which will be a constant of value depending on settings chosen before game starts.
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < ). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!