Advertisement
Guest User

Untitled

a guest
May 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tileWidth; tileWidth = 16;
  2. var tileHeight; tileHeight = 16;
  3. var grid; grid = ds_grid_create(room_width/tileWidth,room_height/tileHeight  )
  4. var map; map = ds_map_create();
  5. //Make sure to add you objects here and their character equivalent.
  6. //ds_map_add(map,object0,'a')
  7. ds_map_add(map,BrickWall,'2')
  8. ds_map_add(map,BlueWall,'3')
  9. ds_map_add(map,TileWall,'4')
  10. ds_map_add(map,RockWall,'10')
  11.  
  12.  
  13.  
  14. ds_grid_set_region(grid,0,0,room_width/tileWidth,room_height/tileHeight,'12');
  15. with(all)
  16. {
  17.  
  18.     if(id <> other.id)
  19.     {
  20.          var char; char = ds_map_find_value(map,object_index)
  21.          if( string(char) = '2')
  22.          {
  23.              char = string(choose(1,1,1,1,1,1,1,1,2,3));
  24.          }
  25.          else if ( string(char) = '3' )
  26.          {
  27.             char = string(choose(4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,6));
  28.          }
  29.          else if ( string(char) = '4')
  30.          {
  31.             char = string(choose(7,7,7,7,7,7,7,8,9));
  32.          }
  33.          ds_grid_set(grid, floor(x/tileWidth),floor(y/tileHeight),char);
  34.     }
  35. }
  36.  
  37. var f; f = file_text_open_append("levels.txt");
  38. file_text_write_string(f,'"');
  39. var xx,yy;
  40. xx = 0;
  41. yy = 0;
  42. repeat(ds_grid_height(grid))
  43. {
  44. repeat(ds_grid_width(grid))
  45. {
  46. file_text_write_string(f,ds_grid_get(grid,xx,yy));
  47. if( (xx + 1) < ds_grid_width(grid))
  48. {
  49.    file_text_write_string(f,',');
  50. }
  51. xx+=1;
  52. }
  53. file_text_write_string(f,'\n');
  54.  
  55. xx = 0;
  56. yy+=1;
  57. }
  58.  
  59. file_text_write_string(f,'",');
  60. file_text_close(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement