Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tileWidth; tileWidth = 16;
- var tileHeight; tileHeight = 16;
- var grid; grid = ds_grid_create(room_width/tileWidth,room_height/tileHeight )
- var map; map = ds_map_create();
- //Make sure to add you objects here and their character equivalent.
- //ds_map_add(map,object0,'a')
- ds_map_add(map,BrickWall,'2')
- ds_map_add(map,BlueWall,'3')
- ds_map_add(map,TileWall,'4')
- ds_map_add(map,RockWall,'10')
- ds_grid_set_region(grid,0,0,room_width/tileWidth,room_height/tileHeight,'12');
- with(all)
- {
- if(id <> other.id)
- {
- var char; char = ds_map_find_value(map,object_index)
- if( string(char) = '2')
- {
- char = string(choose(1,1,1,1,1,1,1,1,2,3));
- }
- else if ( string(char) = '3' )
- {
- char = string(choose(4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,6));
- }
- else if ( string(char) = '4')
- {
- char = string(choose(7,7,7,7,7,7,7,8,9));
- }
- ds_grid_set(grid, floor(x/tileWidth),floor(y/tileHeight),char);
- }
- }
- var f; f = file_text_open_append("levels.txt");
- file_text_write_string(f,'"');
- var xx,yy;
- xx = 0;
- yy = 0;
- repeat(ds_grid_height(grid))
- {
- repeat(ds_grid_width(grid))
- {
- file_text_write_string(f,ds_grid_get(grid,xx,yy));
- if( (xx + 1) < ds_grid_width(grid))
- {
- file_text_write_string(f,',');
- }
- xx+=1;
- }
- file_text_write_string(f,'\n');
- xx = 0;
- yy+=1;
- }
- file_text_write_string(f,'",');
- file_text_close(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement