Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scrSaveLoad()
- {
- if (file_exists("Save_Game.save"))
- {
- room_restart();
- with oObject instance_destroy();
- with oCamera instance_destroy();
- with oPlayer instance_destroy();
- with oGrid instance_destroy();
- with oChar instance_destroy();
- ds_grid_destroy(global.grid)
- 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)
- var _buffer = buffer_load("Save_Game.save");
- var _string = buffer_read(_buffer, buffer_string);
- buffer_delete(_buffer);
- var _loadData = json_parse(_string);
- for (var i = 0; i < array_length(_loadData); ++i)
- {
- if _loadData[i].obj == "oGameManager"
- {
- global.game_fps = _loadData[i].game_fps;
- global.draw_shadows = _loadData[i].draw_shadows;
- global.CameraNum = _loadData[i].CameraNum;
- global.CameraWidth = global.CameraSizes[global.CameraNum][0]
- global.CameraHeight = global.CameraSizes[global.CameraNum][1]
- game_set_speed(global.fps_array[global.game_fps], gamespeed_fps);
- }
- else if _loadData[i].obj == "oPlayer"
- {
- with (instance_create_layer(0, 0, "Instances", asset_get_index(_loadData[i].obj)))
- {
- x = _loadData[i].x;
- y = _loadData[i].y;
- player_speed = _loadData[i].player_speed;
- }
- }
- else if _loadData[i].obj == "oCamera"
- {
- with (instance_create_layer(0, 0, "Instances", asset_get_index(_loadData[i].obj)))
- {
- cameraX = _loadData[i].cameraX;
- cameraY = _loadData[i].cameraY;
- cameraWidth = _loadData[i].cameraWidth;
- cameraHeight = _loadData[i].cameraHeight;
- camera_set_view_pos(global.Camera, cameraX, cameraY);
- camera_set_view_size(global.Camera, cameraWidth, cameraHeight);
- }
- }
- else if _loadData[i].obj == "oGrid"
- {
- with (instance_create_layer(0, 0, "Instances", asset_get_index(_loadData[i].obj)))
- {
- cells_x = _loadData[i].cells_x
- cells_y = _loadData[i].cells_y
- event_user(0); // Вызываем событие создания сетки
- }
- }
- else if _loadData[i].obj == "Tile"
- {
- tilemap_set(map_id_blocks, _loadData[i].tile_block, _loadData[i].cell_x, _loadData[i].cell_y)
- tilemap_set(map_id_block_backs, _loadData[i].tile_backs, _loadData[i].cell_x, _loadData[i].cell_y)
- tilemap_set(map_id_shadows, _loadData[i].tile_shadows, _loadData[i].cell_x, _loadData[i].cell_y)
- ds_grid_set(global.grid, _loadData[i].cell_x, _loadData[i].cell_y, _loadData[i].cost)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement