Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Auto Tile Script
- //iw checks to see if the sprite has another sprite somewhere along the X coordinate
- //auto will be our array to keep track of the 8 surrounding tiles
- //array tracks from top left to bottom right
- var tile,iw,w_left,w_right,w_up,w_down,w_upleft,w_upright,w_downleft,w_downright,auto,binary;
- iw = sprite_width;
- w_left = place_meeting(x-iw,y,object_index);
- w_right = place_meeting(x+iw,y,object_index);
- w_up = place_meeting(x,y-iw,object_index);
- w_down = place_meeting(x,y+iw,object_index);
- w_upright = place_meeting(x-iw,y-iw,object_index);
- w_upleft = place_meeting(x-iw,y+iw,object_index);
- w_downright = place_meeting(x+iw,y-iw,object_index);
- w_downleft = place_meeting(x+iw,y+iw,object_index);
- if (x-iw < 0 ) {w_left = 1; w_upleft = 1; w_downleft = 1;}
- if (x+iw > room_width ) {w_right = 1; w_upright = 1; w_downright = 1;}
- if (y-iw < 0 ) {w_up = 1; w_upleft = 1; w_upright = 1;}
- if (y+iw > room_height ) {w_down = 1; w_downright = 1; w_downleft = 1;}
- auto[7] = w_upleft;
- auto[6] = w_up;
- auto[5] = w_upright;
- auto[4] = w_left;
- auto[3] = w_right;
- auto[2] = w_downleft;
- auto[1] = w_down;
- auto[0] = w_downright;
- if (auto[7] = 1 ) {auto[7] = auto[7] + 9999999}
- if (auto[6] = 1 ) {auto[6] = auto[6] + 999999}
- if (auto[5] = 1 ) {auto[5] = auto[5] + 99999}
- if (auto[4] = 1 ) {auto[4] = auto[4] + 9999}
- if (auto[3] = 1 ) {auto[3] = auto[3] + 999}
- if (auto[2] = 1 ) {auto[2] = auto[2] + 99}
- if (auto[1] = 1 ) {auto[1] = auto[1] + 9}
- //Converts the array into an 8 digit binary number (to represent the 8 surrounding boxes)
- binary = auto[7] + auto[6] + auto[5] + auto[4] + auto[3] + auto[2] + auto[1] + auto[0]
- //Sets default tile
- tile = 0;
- //Sets inner edges
- if (binary = 01111111 ) {tile = 4;}
- if (binary = 01010111 ) {tile = 4;}
- if (binary = 01010110 ) {tile = 4;}
- if (binary = 11011111 ) {tile = 5;}
- if (binary = 01001111 ) {tile = 5;}
- if (binary = 01001011 ) {tile = 5;}
- //Sets Slopes
- if (binary = 00010111 ) {tile = 3;}
- if (binary = 10010111 ) {tile = 3;}
- if (binary = 00001111 ) {tile = 2;}
- if (binary = 00101111 ) {tile = 2;}
- //Sets Edges
- if (binary = 00010000 ) {tile = 7;}
- if (binary = 10010000 ) {tile = 7;}
- if (binary = 00010100 ) {tile = 7;}
- if (binary = 10010100 ) {tile = 7;}
- if (binary = 00001000 ) {tile = 6;}
- if (binary = 00101000 ) {tile = 6;}
- if (binary = 00001001 ) {tile = 6;}
- if (binary = 00101001 ) {tile = 6;}
- //Sets Grass Floor
- if (binary = 00011111 ) {tile = 1;}
- if (binary = 10011111 ) {tile = 1;}
- if (binary = 00111111 ) {tile = 1;}
- if (binary = 00011000 ) {tile = 1;}
- if (binary = 00010110 ) {tile = 1;}
- if (binary = 00001011 ) {tile = 1;}
- if (binary = 00001111 ) {tile = 1;}
- if (binary = 10011000 ) {tile = 1;}
- if (binary = 00111000 ) {tile = 1;}
- if (binary = 00010010 ) {tile = 1;}
- if (binary = 00001010 ) {tile = 1;}
- return tile;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement