GameMaker Automatically Delete Tiles at Y

Okay! I already figured out how to create tiles programmatically in GMS:2

As far as I know, tiles are deleted like so:
Code:
tilemap_set_at_pixel(global.thisTileset, 0, x, y);
SO... I'm wondering how I can effectively delete all tiles at a y value greater than the room_height?
I did try a for loop but that didn't work.

Code:
var tileXCount;
var isEmpty = tilemap_get_at_pixel(global.thisTilemap, tileXCount * 32, room_height * 1.5);

for (tileXCount = 0; tileXCount < (room_width/32); tileXCount++)
{
if (!tile_get_empty(isEmpty))
{
tilemap_set_at_pixel(global.thisTilemap, tileXCount * 32, room_height/2);
}
}

if (tileXCount = room_width/32)
{
tileXCount = 0;
}
If there is some sort of nifty trick I may be missing, please let me know. Thank you!
 
D

Danei

Guest
See what happens if you try this:

Code:
for (var i = room_height/32; i < tilemap_get_height(global.thisTilemap); i++){ //loop through the rows, starting at the bottom of the room
for(var j = 0; j < tilemap_get_width(global.thisTilemap); j++){ //loop through the cells horizontally, starting at 0.

tilemap_set(global.thisTilemap, 0, j, i); // set every cell to 0; there's no need to check if it's empty or not, unless I'm misunderstanding what you want.
//also no need to check pixels when you can loop through using cells instead.

}
}
 
I am mainly trying to get the tiles to delete past the room_height. I intend to make the layer scroll downwards to which any tiles with a y value greater than the room height will be removed as more tiles are created from the top.
 

rIKmAN

Member
I am mainly trying to get the tiles to delete past the room_height. I intend to make the layer scroll downwards to which any tiles with a y value greater than the room height will be removed as more tiles are created from the top.
I believe GM already culls any tiles outside the view, so you don't need to do this manually if you are trying to optimise.
 
Top