G
gadgetkk
Guest
Hello everyone,
I have started dipping into the world of tile maps since everyone seems think this is the bee's knees for GMS 2. While i don't understand much about how they work, i get the gist. So right now have a game that will randomly generate a map using Tiles on a tiles map layer (called tilemap). I will be wanting to allow the player to do a significant amount of manipulations to the tiles map as they will be able to create and destroy tiles while playing.
How can i achieve that?
Here is a code that i have when a tile is clicked:
var i = mouse_x/TILE;
var j = mouse_y/TILE;
if (map_grid[i,j] = WALL)
{
instance_create_layer(i,j,layer,obj_rock_to_mine);
var map_id = layer_tilemap_get_id(tilemap);
var mx = tilemap_get_cell_x_at_pixel(map_id, mouse_x, mouse_y);
var my = tilemap_get_cell_y_at_pixel(map_id, mouse_x, mouse_y);
var data = tilemap_get(map_id, mx, my);
var ind = tile_get_index(data);
data = tile_set_index(data, 0);
tilemap_set(map_id, data, mx, my);
}
The object gets created but the tiles don't go away. Now this is a copy/paste from the manual so it seems to be a bit repetitive in my mind to be done for every click, but once i can get it working i will fiddle with it more.
The error message i get is:
tilemap_get_cell_x_at_pixel() - couldn't find specified tilemap
tilemap_get_cell_y_at_pixel() - couldn't find specified tilemap
tilemap_get() - couldn't find specified tilemap
tilemap_set() - couldn't find specified tilemap
tilemap is a globalvar i use to call the tilemap in different places and it works fine in those other places. I appreciate anyone who can assist me.
Also, if there is an easier way to do what i want please let me know.
Also also, can anyone explain to me what "tiledata" is in the manual example? I have no idea what that is indicating and i can't find any information on that field anywhere.
Thanks.
I have started dipping into the world of tile maps since everyone seems think this is the bee's knees for GMS 2. While i don't understand much about how they work, i get the gist. So right now have a game that will randomly generate a map using Tiles on a tiles map layer (called tilemap). I will be wanting to allow the player to do a significant amount of manipulations to the tiles map as they will be able to create and destroy tiles while playing.
How can i achieve that?
Here is a code that i have when a tile is clicked:
var i = mouse_x/TILE;
var j = mouse_y/TILE;
if (map_grid[i,j] = WALL)
{
instance_create_layer(i,j,layer,obj_rock_to_mine);
var map_id = layer_tilemap_get_id(tilemap);
var mx = tilemap_get_cell_x_at_pixel(map_id, mouse_x, mouse_y);
var my = tilemap_get_cell_y_at_pixel(map_id, mouse_x, mouse_y);
var data = tilemap_get(map_id, mx, my);
var ind = tile_get_index(data);
data = tile_set_index(data, 0);
tilemap_set(map_id, data, mx, my);
}
The object gets created but the tiles don't go away. Now this is a copy/paste from the manual so it seems to be a bit repetitive in my mind to be done for every click, but once i can get it working i will fiddle with it more.
The error message i get is:
tilemap_get_cell_x_at_pixel() - couldn't find specified tilemap
tilemap_get_cell_y_at_pixel() - couldn't find specified tilemap
tilemap_get() - couldn't find specified tilemap
tilemap_set() - couldn't find specified tilemap
tilemap is a globalvar i use to call the tilemap in different places and it works fine in those other places. I appreciate anyone who can assist me.
Also, if there is an easier way to do what i want please let me know.
Also also, can anyone explain to me what "tiledata" is in the manual example? I have no idea what that is indicating and i can't find any information on that field anywhere.
Thanks.