Advertisement
Guest User

Testing Auto Tile Generator - Game Maker

a guest
Apr 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. //Auto Tile Script
  2. //iw checks to see if the sprite has another sprite somewhere along the X coordinate
  3. //auto will be our array to keep track of the 8 surrounding tiles
  4. //array tracks from top left to bottom right
  5.  
  6. var tile,iw,w_left,w_right,w_up,w_down,w_upleft,w_upright,w_downleft,w_downright,auto,binary;
  7.  
  8. iw = sprite_width;
  9. w_left = place_meeting(x-iw,y,object_index);
  10. w_right = place_meeting(x+iw,y,object_index);
  11. w_up = place_meeting(x,y-iw,object_index);
  12. w_down = place_meeting(x,y+iw,object_index);
  13. w_upright = place_meeting(x-iw,y-iw,object_index);
  14. w_upleft = place_meeting(x-iw,y+iw,object_index);
  15. w_downright = place_meeting(x+iw,y-iw,object_index);
  16. w_downleft = place_meeting(x+iw,y+iw,object_index);
  17.  
  18. if (x-iw < 0 ) {w_left = 1; w_upleft = 1; w_downleft = 1;}
  19. if (x+iw > room_width ) {w_right = 1; w_upright = 1; w_downright = 1;}
  20. if (y-iw < 0 ) {w_up = 1; w_upleft = 1; w_upright = 1;}
  21. if (y+iw > room_height ) {w_down = 1; w_downright = 1; w_downleft = 1;}
  22.  
  23. auto[7] = w_upleft;
  24. auto[6] = w_up;
  25. auto[5] = w_upright;
  26. auto[4] = w_left;
  27. auto[3] = w_right;
  28. auto[2] = w_downleft;
  29. auto[1] = w_down;
  30. auto[0] = w_downright;
  31.  
  32. if (auto[7] = 1 ) {auto[7] = auto[7] + 9999999}
  33. if (auto[6] = 1 ) {auto[6] = auto[6] + 999999}
  34. if (auto[5] = 1 ) {auto[5] = auto[5] + 99999}
  35. if (auto[4] = 1 ) {auto[4] = auto[4] + 9999}
  36. if (auto[3] = 1 ) {auto[3] = auto[3] + 999}
  37. if (auto[2] = 1 ) {auto[2] = auto[2] + 99}
  38. if (auto[1] = 1 ) {auto[1] = auto[1] + 9}
  39.  
  40. //Converts the array into an 8 digit binary number (to represent the 8 surrounding boxes)
  41. binary = auto[7] + auto[6] + auto[5] + auto[4] + auto[3] + auto[2] + auto[1] + auto[0]
  42.  
  43. //Sets default tile
  44. tile = 0;
  45.  
  46. //Sets inner edges
  47. if (binary = 01111111 ) {tile = 4;}
  48. if (binary = 01010111 ) {tile = 4;}
  49. if (binary = 01010110 ) {tile = 4;}
  50. if (binary = 11011111 ) {tile = 5;}
  51. if (binary = 01001111 ) {tile = 5;}
  52. if (binary = 01001011 ) {tile = 5;}
  53.  
  54. //Sets Slopes
  55. if (binary = 00010111 ) {tile = 3;}
  56. if (binary = 10010111 ) {tile = 3;}
  57. if (binary = 00001111 ) {tile = 2;}
  58. if (binary = 00101111 ) {tile = 2;}
  59.  
  60. //Sets Edges
  61. if (binary = 00010000 ) {tile = 7;}
  62. if (binary = 10010000 ) {tile = 7;}
  63. if (binary = 00010100 ) {tile = 7;}
  64. if (binary = 10010100 ) {tile = 7;}
  65. if (binary = 00001000 ) {tile = 6;}
  66. if (binary = 00101000 ) {tile = 6;}
  67. if (binary = 00001001 ) {tile = 6;}
  68. if (binary = 00101001 ) {tile = 6;}
  69.  
  70. //Sets Grass Floor
  71. if (binary = 00011111 ) {tile = 1;}
  72. if (binary = 10011111 ) {tile = 1;}
  73. if (binary = 00111111 ) {tile = 1;}
  74. if (binary = 00011000 ) {tile = 1;}
  75. if (binary = 00010110 ) {tile = 1;}
  76. if (binary = 00001011 ) {tile = 1;}
  77. if (binary = 00001111 ) {tile = 1;}
  78. if (binary = 10011000 ) {tile = 1;}
  79. if (binary = 00111000 ) {tile = 1;}
  80. if (binary = 00010010 ) {tile = 1;}
  81. if (binary = 00001010 ) {tile = 1;}
  82.  
  83. return tile;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement