Hello everybody, I have previously make a thread asking wheter structures(GMS 2.3) are good for storing info about tiles, and even without receiving a positive answer I decided to use them in the Level Editor to test before implementing in new Games. But now when I am done with Level Editor and the time has come to implement many of the new changes I have to find out the best data structure to hold info about tiels. Currently my structure is like that:
So, the question is what to choose from the options for storing Tile Info:
1. Structures: leave the things as they are. The biggest con of structures is ability to use Sprite Index, Image index and other integrated GML variables and easy readable code for them.
2. Enumerated Arrays. I think the biggest con of this option is that Arrays are probably quicker than structures. But here is the main problem, I just don't know if they are.
3. I also thought about ds_list like in GameMaker Rob's tutorial, because they are easy to save I guess.
And by the way, if you don't mind I have 2 questions actually. Which is the best way to save and load Level Info containing such Tile Info + A few Objects, .ini or .json???
GML:
//Create Event of the Manager Object
map_grid = ds_grid_create(grid_W,grid_H)
global.top_heights_grid = ds_grid_create(grid_W,grid_H);
for(var W = 0;W < grid_W; W++)
{
for(var H = 0;H < grid_H;H++)
{
//Tile = {gridX,gridY,Height,ScreenX,ScreenY,Sprite,SpriteFrame,ON_TILE,Collision,Cursor}
global.top_heights_grid[# W,H] = 0;
map_grid[# W,H] = array_create(grid_levels);//Grid levels = 4;
var _sprite_frame = 0;
var _sprite = spr_tiles;
var _tile = new GameTile(W,H,0,_sprite,_sprite_frame);
map_grid[# W,H][@ 0] = _tile;
}
}
//Game Tile Constructor
function GameTile(_tileX,_tileY,_height,_sprite,_sprite_frame) constructor
{
tileX = _tileX;
tileY = _tileY;
height = _height;
x = TileToScreenX(_tileX,_tileY);
y = TileToScreenY(_tileX,_tileY,_height);
sprite_index = _sprite;
image_index = _sprite_frame;
on_tile = noone;
collision = false;
cursor = -1;
global.top_heights_grid[# _tileX,_tileY] = max(global.top_heights_grid[# _tileX,_tileY],_height);
}
1. Structures: leave the things as they are. The biggest con of structures is ability to use Sprite Index, Image index and other integrated GML variables and easy readable code for them.
2. Enumerated Arrays. I think the biggest con of this option is that Arrays are probably quicker than structures. But here is the main problem, I just don't know if they are.
3. I also thought about ds_list like in GameMaker Rob's tutorial, because they are easy to save I guess.
And by the way, if you don't mind I have 2 questions actually. Which is the best way to save and load Level Info containing such Tile Info + A few Objects, .ini or .json???