GameMaker Tile Ids wrong when Flipped or Rotated, Is it a Bug?

So I'm working something to gather the tiles in a tilemap and copy them. Something strange, that may be a bug in GM Studio 2, happens to the tile ids when they are flipped, or rotated in the room editor. The tile ids become huge numbers. This makes reading, and understanding which tile it actually is on the tilemap very difficult. It also makes tile specific operations based on which tile it is very difficult. Try the download below to see it in action, or view the screenshot.

The huge numbers fit with the operation done + what the id would be if it weren't altered. The altered number are different if x flipped, y flipped, xy flipped, rotated, rotated and x flipped, rotated and y flipped, and rotated and xy flipped.

Is this a bug or intentional so GM internally knows all a tile's properties from one number by messing up the tile ids this way?

Tile ID Changes On Flipping and Rotating
 

Attachments

So the tile data is a number that holds multiple bits of data: the tile is, flipped, rotated, mirrored, etc.
Luckily you can easily get it the index out by using tile_get_index

https://docs2.yoyogames.com/source/..._reference/rooms/tilemaps/tile_get_index.html
Ok I was getting the id from tilemap_get_at_pixel, after using tile_get_index on the result from that previous command I'm getting a correct result now. I thought the first command was for this, and it worked until I flipped and rotated tiles. Didn't know getting to the id required this many commands, or whether "tile data" meant id (apparently not). So the first command finds the tile mask then? Thanks!
 

rIKmAN

Member
Ok I was getting the id from tilemap_get_at_pixel, after using tile_get_index on the result from that previous command I'm getting a correct result now. I thought the first command was for this, and it worked until I flipped and rotated tiles. Didn't know getting to the id required this many commands, or whether "tile data" meant id (apparently not). So the first command finds the tile mask then? Thanks!
If the tile has not been rotated or flipped etc then tilemap_get_at_pixel will return the tile index, but as soon as you you set those the bitmask is used to store this data so you then need to use those functions mentioned to get at it.
 
Tile data is not index.
It's index and rotation info etc.
Does jamming those types of data together allow something useful to us? What's the purpose of having to do an extra step to get the tile id, lookup efficiency in the tile system or something?
 

GMWolf

aka fel666
Does jamming those types of data together allow something useful to us? What's the purpose of having to do an extra step to get the tile id, lookup efficiency in the tile system or something?
Yeah it's very memory efficient, and it's ver efficient for the GPU to use that data too.
It's better for cache, etc etc.

You can also retrieve the tile index by andimg it with the tile index mask (I forget what the actual variable is but I'm sure someone here will know)
Something like
Code:
var index = tilemap_get_tile(...) & tile_index_mask;
Those function and variable names I made up since I don't remember them off the top of my head but you should be able to find the right ones in the manual.

I think another great advantage is that in GM, we don't have structs. So returning the data like this is far more efficient than returning it as an array or something.
 
Top