GameMaker Mirrior,Flip, Rotate All Tiles in Tilemap in Code

Say I want to be able mirrior, flip, and rotate all the tiles in a tilemap (in game not in room editor). Also to be able to do one, some, or all of these operations, and turn all these off too. What's the best way to do this?
 
Ok after trying this below I have questions.

Event: Key Press ( Any Key)

var lay_id = layer_get_id("Tiles_sky");
var map_id = layer_tilemap_get_id(lay_id);
var mask = tile_mirror | tile_flip | tile_rotate | 255;
tilemap_set_mask(map_id, mask);

It doesn't seem to do anything when I run it (even when altering the values between the ands), is there some setup stuff other than having a tilemap with that name in the room and having this code in an object in the room in a key press event, and pressing the key to test it?

Secondly how would I change this line for the cases below it?

var mask = tile_mirror | tile_flip | tile_rotate | 255;

Would you write setting them all in a direction like this, or some other way?

new_mask = 1 | 1 | 1 | 255

Would reversing work like this?

new_mask = !tile_mirror | !tile_flip | !tile_rotate | 255;

What values do the places where tile_mirrior, tile_flip, and tile_rotate are actually take?
 

TheouAegis

Member
You don't mirror, flip, rotate the tiles in the tile map, you do that to the tiles in the room. The tile map is just a palette of colors, except each color is a complete tile. tilemap_set_mask is for setting the mask, which is used for separating the index of a tile in the room from the properties of that tile.
 
You don't mirror, flip, rotate the tiles in the tile map, you do that to the tiles in the room. The tile map is just a palette of colors, except each color is a complete tile. tilemap_set_mask is for setting the mask, which is used for separating the index of a tile in the room from the properties of that tile.
So Arashi was incorrect for pointing me there? If so, then I take it tile_get_rotate(tiledata, rotate), tile_set_rotate(tiledata ect rotate), and the like for mirroring, and flipping is code I should use. How does one do that with more than one property at a time on each tile? In the example given in the manual below it only sets one tile's rotation, what if I want to set the entire tilemap/tile layer and multiple properties of each tile? I guess going through it like a 2d array would work, but the multiple tile properties is where I'm confused about what to do.

Manual example

var lay_id = layer_get_id("Tiles_sky");
var map_id = layer_tilemap_get_id(lay_id);
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 bool = !tile_get_rotate(data);
data = tile_set_rotate(data, bool);
tilemap_set(map_id, data, mx, my);

Starting at the last 3 lines, do I need to copy them like below if I want to change multiple tile properties of one tile at once. Setting the values and tilemap 3 times for each tile seems expensive for doing the entire tilemap, but is this how I should do it for each tile?

var bool = !tile_get_rotate(data);
data = tile_set_rotate(data, bool);
tilemap_set(map_id, data, mx, my);

var bool = !tile_get_mirror(data);
data = tile_set_mirror(data, bool);
tilemap_set(map_id, data, mx, my);

var bool = !tile_get_flip(data);
data = tile_set_flip(data, bool);
tilemap_set(map_id, data, mx, my);

Lastly should I check if a tile is already set to the rotation, mirroring, flipping values (when not negating them based on their actual values) before doing tilemap_set, or will adding such a check waste cpu cycles?
 
Last edited:
Top