Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scrSave()
- {
- var data = array_create(0);
- var settings =
- {
- obj : object_get_name(object_index),
- draw_shadows : global.draw_shadows,
- game_fps : global.game_fps,
- CameraNum : global.CameraNum
- }
- array_push(data, settings)
- if instance_exists(oObject)
- {
- with oObject
- {
- var saveData =
- {
- obj : object_get_name(object_index),
- x : x,
- y : y,
- hp : hp,
- coordx : coordx,
- coordy : coordy,
- flammable : flammable,
- visible : visible,
- image_index : image_index,
- cur_neighbors : cur_neighbors,
- }
- array_push(data, saveData)
- }
- }
- if instance_exists(oPlayer)
- {
- with oPlayer
- {
- var saveData =
- {
- obj : object_get_name(object_index),
- x : x,
- y : y,
- player_speed : player_speed,
- }
- array_push(data, saveData)
- }
- }
- if instance_exists(oCamera)
- {
- with oCamera
- {
- var saveData =
- {
- obj : object_get_name(object_index),
- cameraX : cameraX,
- cameraY : cameraY,
- cameraWidth : cameraWidth,
- cameraHeight : cameraHeight,
- }
- array_push(data, saveData)
- }
- }
- if instance_exists(oGrid)
- {
- // Сперва заносим общую информацию по полю
- with oGrid
- {
- var saveData =
- {
- obj : object_get_name(object_index),
- cells_x : cells_x,
- cells_y : cells_y,
- }
- array_push(data, saveData)
- }
- // Затем заносим информацию по объектам
- with oGrid
- {
- var lay_id_blocks = layer_get_id("BlockLayer");
- var map_id_blocks = layer_tilemap_get_id(lay_id_blocks)
- var lay_id_block_backs = layer_get_id("Backs");
- var map_id_block_backs = layer_tilemap_get_id(lay_id_block_backs)
- var lay_id_shadows = layer_get_id("ShadowLayer");
- var map_id_shadows = layer_tilemap_get_id(lay_id_shadows)
- for (var _y = 0; _y < cells_y; ++_y)
- {
- for (var _x = 0; _x < cells_x; ++_x)
- {
- var saveData =
- {
- obj : "Tile",
- cell_x : _x,
- cell_y : _y,
- tile_block : tilemap_get(map_id_blocks, _x, _y),
- tile_backs : tilemap_get(map_id_block_backs, _x, _y),
- tile_shadows : tilemap_get(map_id_shadows, _x, _y),
- cost : ds_grid_get(global.grid, _x, _y),
- }
- array_push(data, saveData)
- }
- }
- }
- }
- var _string = json_stringify(data);
- var _buffer = buffer_create(string_byte_length(_string) + 1, buffer_fixed, 1);
- buffer_write(_buffer, buffer_string, _string);
- buffer_save(_buffer, "Save_Game.save");
- buffer_delete(_buffer);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement