I'm sure it's something dumb and easy but I have been racking my brain for days over this. essentially, these lines of code return a boolean that gets multiplied and returns an index to be converted into an image_index and helping me autotile while running my game. problem is that it only works when there is one terrain type so I put checks in that if the boolean returns true that it would take the id of the nearby tiles and check if they are the same terrain type(blockType) and if they aren't then I'd set the boolean to negative. I figured that would work but it seems to completely throw off the math and I'm not sure why that is.
size = sprite_width;
//Directional Check, including corners, returns Boolean
north_tile = place_meeting(x,y-size,obj_stamp);
south_tile = place_meeting(x,y+size,obj_stamp);
west_tile = place_meeting(x-size,y,obj_stamp);
east_tile = place_meeting(x+size,y,obj_stamp);
north_west_tile = place_meeting(x-size,y-size,obj_stamp) && west_tile && north_tile;
north_east_tile = place_meeting(x+size,y-size,obj_stamp) && north_tile && east_tile;
south_west_tile = place_meeting(x-size,y+size,obj_stamp) && south_tile && west_tile;
south_east_tile = place_meeting(x+size,y+size,obj_stamp) && south_tile && east_tile;
if (north_tile = 1)
{
north_tileid = instance_position(x,y-size,obj_stamp);
if (north_tileid != noone)
{
if (blockType != north_tileid.blockType)
{
north_tile = false;
north_tileid = 0;
}
}
}
if (south_tile = 1)
{
south_tileid = instance_position(x,y+size,obj_stamp);
if (south_tileid != noone)
{
if (blockType != south_tileid.blockType)
{
south_tile = false;
south_tileid = 0;
}
}
}
if (west_tile = 1)
{
west_tileid = instance_position(x-size,y,obj_stamp);
if (west_tileid != noone)
{
if (blockType != west_tileid.blockType)
{
west_tile = false;
west_tileid = 0;
}
}
}
if (east_tile = 1)
{
east_tileid = instance_position(x+size,y,obj_stamp);
if (east_tileid != noone)
{
if (blockType != east_tileid.blockType)
{
east_tile = false;
east_tileid = 0;
}
}
}
if (north_west_tile = 1)
{
north_west_tileid = instance_position(x-size,y-size,obj_stamp);
if (north_west_tileid != noone)
{
if (blockType != north_west_tileid.blockType)
{
north_west_tile = false && north_tile && west_tile;
north_west_tileid = 0;
}
}
}
if (north_east_tile = 1)
{
north_east_tileid = instance_position(x+size,y-size,obj_stamp);
if (north_east_tileid != noone)
{
if (blockType != north_east_tileid.blockType)
{
north_east_tile = false && north_tile && east_tile;
north_east_tileid = 0;
}
}
}
if (south_west_tile = 1)
{
south_west_tileid = instance_position(x-size,y+size,obj_stamp);
if (south_west_tileid != noone)
{
if (blockType != south_west_tileid.blockType)
{
south_west_tile = false && south_tile && west_tile;
south_west_tileid = 0;
}
}
}
if (south_east_tile = 1)
{
south_east_tileid = instance_position(x+size,y+size,obj_stamp);
if (south_east_tileid != noone)
{
if (blockType != south_east_tileid.blockType)
{
south_east_tile = false && south_tile && east_tile;
south_east_tileid = 0;
}
}
}
//8 bit Bitmasking calculation using Directional check booleans values
index = north_west_tile + 2*north_tile + 4*north_east_tile + 8*west_tile + 16*east_tile + 32*south_west_tile + 64*south_tile + 128*south_east_tile;
// tile image_index
// "254": 45, "90": 22, "22": 7,
//"0": 47, "10": 3, "2": 1, "94": 24,
//"120": 29, "11": 4, "208": 34, "107": 28,
//"82": 19, "216": 37, "86": 20, "223": 41,
//"214": 36, "104": 26,
//"222": 40, "74": 16, "18": 6, "8": 2,
//"248": 42, "255": 46, "127": 33, "123": 31,
//"66": 14, "16": 5, "219": 39, "75": 17, "80": 18,
//"122": 30, "30": 11, "126": 32, "31": 12,
//"250": 43, "88": 21, "64": 13, "95": 25,
//"251": 44, "91": 23, "24": 8, "27": 10, "218": 38,
//"72": 15, "106": 27, "26": 9, "210": 35
if (index = 254)
{
image_index = 45;
}
if (index = 90)
{
image_index = 22;
}
if (index = 22)
{
image_index = 7;
}
if (index = 0)
{
image_index = 47;
}
if (index = 10)
{
image_index = 3;
}
if (index = 2)
{
image_index = 1;
}
if (index = 94)
{
image_index = 24;
}
if (index = 120)
{
image_index = 29;
}
if (index = 11)
{
image_index = 4;
}
if (index = 208)
{
image_index = 34;
}
if (index = 107)
{
image_index = 28;
}
if (index = 82)
{
image_index = 19;
}
if (index = 216)
{
image_index = 37;
}
if (index = 86)
{
image_index = 20;
}
if (index = 223)
{
image_index = 41;
}
if (index = 214)
{
image_index = 36;
}
if (index = 104)
{
image_index = 26;
}
if (index = 222)
{
image_index = 40;
}
if (index = 74)
{
image_index = 16;
}
if (index = 18)
{
image_index = 6;
}
if (index = 8)
{
image_index = 2;
}
if (index = 248)
{
image_index = 42;
}
if (index = 255)
{
image_index = 46;
}
if (index = 127)
{
image_index = 33;
}
if (index = 123)
{
image_index = 31;
}
if (index = 66)
{
image_index = 14;
}
if (index = 16)
{
image_index = 5;
}
if (index = 219)
{
image_index = 39;
}
if (index = 75)
{
image_index = 17;
}
if (index = 80)
{
image_index = 18;
}
if (index = 122)
{
image_index = 30;
}
if (index = 30)
{
image_index = 11;
}
if (index = 126)
{
image_index = 32;
}
if (index = 31)
{
image_index = 12;
}
if (index = 250)
{
image_index = 43;
}
if (index = 88)
{
image_index = 21;
}
if (index = 64)
{
image_index = 13;
}
if (index = 95)
{
image_index = 25;
}
if (index = 251)
{
image_index = 44;
}
if (index = 91)
{
image_index = 23;
}
if (index = 24)
{
image_index = 8;
}
if (index = 27)
{
image_index = 10;
}
if (index = 218)
{
image_index = 38;
}
if (index = 72)
{
image_index = 15;
}
if (index = 106)
{
image_index = 27;
}
if (index = 26)
{
image_index = 9;
}
if (index = 210)
{
image_index = 35;
}
size = sprite_width;
//Directional Check, including corners, returns Boolean
north_tile = place_meeting(x,y-size,obj_stamp);
south_tile = place_meeting(x,y+size,obj_stamp);
west_tile = place_meeting(x-size,y,obj_stamp);
east_tile = place_meeting(x+size,y,obj_stamp);
north_west_tile = place_meeting(x-size,y-size,obj_stamp) && west_tile && north_tile;
north_east_tile = place_meeting(x+size,y-size,obj_stamp) && north_tile && east_tile;
south_west_tile = place_meeting(x-size,y+size,obj_stamp) && south_tile && west_tile;
south_east_tile = place_meeting(x+size,y+size,obj_stamp) && south_tile && east_tile;
if (north_tile = 1)
{
north_tileid = instance_position(x,y-size,obj_stamp);
if (north_tileid != noone)
{
if (blockType != north_tileid.blockType)
{
north_tile = false;
north_tileid = 0;
}
}
}
if (south_tile = 1)
{
south_tileid = instance_position(x,y+size,obj_stamp);
if (south_tileid != noone)
{
if (blockType != south_tileid.blockType)
{
south_tile = false;
south_tileid = 0;
}
}
}
if (west_tile = 1)
{
west_tileid = instance_position(x-size,y,obj_stamp);
if (west_tileid != noone)
{
if (blockType != west_tileid.blockType)
{
west_tile = false;
west_tileid = 0;
}
}
}
if (east_tile = 1)
{
east_tileid = instance_position(x+size,y,obj_stamp);
if (east_tileid != noone)
{
if (blockType != east_tileid.blockType)
{
east_tile = false;
east_tileid = 0;
}
}
}
if (north_west_tile = 1)
{
north_west_tileid = instance_position(x-size,y-size,obj_stamp);
if (north_west_tileid != noone)
{
if (blockType != north_west_tileid.blockType)
{
north_west_tile = false && north_tile && west_tile;
north_west_tileid = 0;
}
}
}
if (north_east_tile = 1)
{
north_east_tileid = instance_position(x+size,y-size,obj_stamp);
if (north_east_tileid != noone)
{
if (blockType != north_east_tileid.blockType)
{
north_east_tile = false && north_tile && east_tile;
north_east_tileid = 0;
}
}
}
if (south_west_tile = 1)
{
south_west_tileid = instance_position(x-size,y+size,obj_stamp);
if (south_west_tileid != noone)
{
if (blockType != south_west_tileid.blockType)
{
south_west_tile = false && south_tile && west_tile;
south_west_tileid = 0;
}
}
}
if (south_east_tile = 1)
{
south_east_tileid = instance_position(x+size,y+size,obj_stamp);
if (south_east_tileid != noone)
{
if (blockType != south_east_tileid.blockType)
{
south_east_tile = false && south_tile && east_tile;
south_east_tileid = 0;
}
}
}
//8 bit Bitmasking calculation using Directional check booleans values
index = north_west_tile + 2*north_tile + 4*north_east_tile + 8*west_tile + 16*east_tile + 32*south_west_tile + 64*south_tile + 128*south_east_tile;
// tile image_index
// "254": 45, "90": 22, "22": 7,
//"0": 47, "10": 3, "2": 1, "94": 24,
//"120": 29, "11": 4, "208": 34, "107": 28,
//"82": 19, "216": 37, "86": 20, "223": 41,
//"214": 36, "104": 26,
//"222": 40, "74": 16, "18": 6, "8": 2,
//"248": 42, "255": 46, "127": 33, "123": 31,
//"66": 14, "16": 5, "219": 39, "75": 17, "80": 18,
//"122": 30, "30": 11, "126": 32, "31": 12,
//"250": 43, "88": 21, "64": 13, "95": 25,
//"251": 44, "91": 23, "24": 8, "27": 10, "218": 38,
//"72": 15, "106": 27, "26": 9, "210": 35
if (index = 254)
{
image_index = 45;
}
if (index = 90)
{
image_index = 22;
}
if (index = 22)
{
image_index = 7;
}
if (index = 0)
{
image_index = 47;
}
if (index = 10)
{
image_index = 3;
}
if (index = 2)
{
image_index = 1;
}
if (index = 94)
{
image_index = 24;
}
if (index = 120)
{
image_index = 29;
}
if (index = 11)
{
image_index = 4;
}
if (index = 208)
{
image_index = 34;
}
if (index = 107)
{
image_index = 28;
}
if (index = 82)
{
image_index = 19;
}
if (index = 216)
{
image_index = 37;
}
if (index = 86)
{
image_index = 20;
}
if (index = 223)
{
image_index = 41;
}
if (index = 214)
{
image_index = 36;
}
if (index = 104)
{
image_index = 26;
}
if (index = 222)
{
image_index = 40;
}
if (index = 74)
{
image_index = 16;
}
if (index = 18)
{
image_index = 6;
}
if (index = 8)
{
image_index = 2;
}
if (index = 248)
{
image_index = 42;
}
if (index = 255)
{
image_index = 46;
}
if (index = 127)
{
image_index = 33;
}
if (index = 123)
{
image_index = 31;
}
if (index = 66)
{
image_index = 14;
}
if (index = 16)
{
image_index = 5;
}
if (index = 219)
{
image_index = 39;
}
if (index = 75)
{
image_index = 17;
}
if (index = 80)
{
image_index = 18;
}
if (index = 122)
{
image_index = 30;
}
if (index = 30)
{
image_index = 11;
}
if (index = 126)
{
image_index = 32;
}
if (index = 31)
{
image_index = 12;
}
if (index = 250)
{
image_index = 43;
}
if (index = 88)
{
image_index = 21;
}
if (index = 64)
{
image_index = 13;
}
if (index = 95)
{
image_index = 25;
}
if (index = 251)
{
image_index = 44;
}
if (index = 91)
{
image_index = 23;
}
if (index = 24)
{
image_index = 8;
}
if (index = 27)
{
image_index = 10;
}
if (index = 218)
{
image_index = 38;
}
if (index = 72)
{
image_index = 15;
}
if (index = 106)
{
image_index = 27;
}
if (index = 26)
{
image_index = 9;
}
if (index = 210)
{
image_index = 35;
}