Ember

Autotile

Jun 7th, 2011
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Check for surrounding objects
  2. var xx, yy, obj, check, terrain;
  3. terrain = argument0;
  4. obj = argument1;
  5. xx = argument2;
  6. yy = argument3;
  7. check = 0;
  8.  
  9. //This is the checking
  10. if !instance_position(xx+20,yy,obj) {check += 2;}
  11. if !instance_position(xx,yy-20,obj) {check += 4;}
  12. if !instance_position(xx-20,yy,obj) {check += 8;}
  13. if !instance_position(xx,yy+20,obj) {check += 16;}
  14.  
  15. //Now check diagonally
  16. if check = 0 {
  17. if !instance_position(xx+20,yy-20,obj) {check += 32;} else
  18. if !instance_position(xx-20,yy-20,obj) {check += 64;} else
  19. if !instance_position(xx-20,yy+20,obj) {check += 128;} else
  20. if !instance_position(xx+20,yy+20,obj) {check += 256;}
  21. }
  22.  
  23. //Generate tile accordingly
  24. execute_string(global.t_add[check],terrain,xx,yy);
Advertisement
Add Comment
Please, Sign In to add comment