Hello! I am very new with gml. I am trying to create an Isometric world with the use of a ds_grid. But if I try to create a very big room that is filled with isometric tiles I get major performance issues.
Since I am very new with gml I don't know all the options to increase performance of drawing a static isometric floor.
I draw the tiles that are only in view, that helped a little. I have seen options to work with chunks, vertex buffers and buffers. But I have no idea how to implement them correctly.
I would love some advice and ideas to improve the current code.
Create event:
Draw event:
In game image
Ps, sorry for the bad english.
Since I am very new with gml I don't know all the options to increase performance of drawing a static isometric floor.
I draw the tiles that are only in view, that helped a little. I have seen options to work with chunks, vertex buffers and buffers. But I have no idea how to implement them correctly.
I would love some advice and ideas to improve the current code.
Create event:
GML:
// Set the layer to not visable
layer_set_visible("Tile_layer_1", false);
// Create a grid based on the map width and height in tiles (32 x 32 = 1 tile)
global.map_grid = ds_grid_create(MAP_W_IN_TILES, MAP_H_IN_TILES); // Grid starts at 0, 0
// Get the Tilemap that needs to be converted
var tile_map = layer_tilemap_get_id("Tile_layer_1");
// For each tile in the grid apply data
for (var tX = 0; tX < MAP_W_IN_TILES; tX++){
for (var tY = 0; tY < MAP_H_IN_TILES; tY++){
var tilemap_data = tilemap_get(tile_map, tX, tY);
// Format: [Tile, Z]
var this_tile = [-1, 0];
this_tile[TILE.SPRITE] = tilemap_data;
this_tile[TILE.Z] = 0;
global.map_grid[# tX, tY] = this_tile;
}
}
GML:
/// Render Isometric Game
var tilemap_data, roomX, roomY, tile_index, tile_z;
// Convert map_data from grid to isometric tiles
// Go through / for each tile in the grid
for (var tX = 0; tX < MAP_W_IN_TILES; tX++){
for (var tY = 0; tY < MAP_H_IN_TILES; tY++){
tilemap_data = global.map_grid[# tX, tY];
roomX = Iso_TileToSceenX(tX, tY);
roomY = Iso_TileToSceenY(tX, tY);
// Only draw when tile is in view
if tile_inview(roomX, roomY) {
tile_index = tilemap_data[TILE.SPRITE];
tile_z = tilemap_data[TILE.Z];
// If there is a tile_ index with a value more than 0 and in view, then draw the designated tile
if (tile_index != EMPTY_TILE) {
// Apply shaders for specific tiles
// Depth shader
if tile_index != EMPTY_TILE shader_set(depth_shader);
var tileposval = tX + tY;
shader_set_uniform_f(shader_get_uniform(depth_shader, "tilepos"), tileposval * 0.02);
// Water shader
if tile_index == WATER_TILE shader_set(water_shader);
// Draw the tile
draw_tile(TileSetIso, tile_index, 0, roomX, roomY + tile_z);
// Cleanup
shader_reset();
}
// If the mouse is hovering over a tile, set Selection tile
if (Iso_ScreenToTileX(mouse_x, mouse_y) == tX) && (Iso_ScreenToTileY(mouse_x, mouse_y) == tY){
draw_tile(TileSetIso, SELECTION_TILE, 0, roomX, roomY + tile_z);
}
}
}
}
Ps, sorry for the bad english.
Last edited: