Created
April 1, 2026 02:42
-
-
Save attic-stuff/6eb6c0189181305576da1d9fcfd0d3ef to your computer and use it in GitHub Desktop.
converts compressed tile data from a yy file into a runtime tilemap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * converts compressed tile data from a room yy file into a runtime tilemap | |
| * @param {array<real>} compressed_tile_data the "TileCompressedData" from the yy file | |
| * @param {string} tilemap_name the string name of the tilemap layer to populate | |
| * @param {real} tilemap_columns the number of columns in the tilemap being populated | |
| */ | |
| function compressed_tile_data_to_tilemap(compressed_tile_data, tilemap_name, tilemap_columns) { | |
| var tilemap_layer = layer_tilemap_get_id(tilemap_name); | |
| var tile_index = 0; | |
| while (array_length(compressed_tile_data) > 0) { | |
| var instruction_value = array_shift(compressed_tile_data); | |
| var instruction_sign = sign(instruction_value); | |
| if (instruction_sign == 1) { | |
| repeat (instruction_value) { | |
| tilemap_set(tilemap_layer, array_shift(compressed_tile_data), tile_index mod tilemap_columns, tile_index div tilemap_columns); | |
| tile_index = tile_index + 1; | |
| } | |
| } | |
| if (instruction_sign == -1) { | |
| var fill_index = array_shift(compressed_tile_data) & 127; | |
| repeat (instruction_value * -1) { | |
| tilemap_set(tilemap_layer, fill_index, tile_index mod tilemap_columns, tile_index div tilemap_columns); | |
| tile_index = tile_index + 1; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment