pixeltroid
Member
I have a basic save/load feature that enables me to load game from the last room that he was in. It saves the status of bosses killed, doors open and keys collected. It works perfectly except for one major flaw:
when I load a game, the player spawns a little away from where he was when the game was saved (by selecting "save" from the pause menu). This results in player spawning in the floor or a wall, thus making the game unplayable!
Here's my save game script:
Here is my load game script:
How can I fix this?
---------------------------------------------------------------------
Also, is there a way to change my script so that the loaded game makes player starts in the ENTRANCE of the room where he respawns after he dies? Because each room has a very specific starting point established in a room change object.
For example: If I have to go to a room, player needs to touch a door object with this code:
The same door object contains a creation code in the room editor:
Any help will be appreciated!
when I load a game, the player spawns a little away from where he was when the game was saved (by selecting "save" from the pause menu). This results in player spawning in the floor or a wall, thus making the game unplayable!
Here's my save game script:
Code:
with (argument0){
ini_open("save.ini");
roomAlias = "1A" //default room
//SAVE Room
if (room=room1A) roomAlias = "1A"
if (room=room1B) roomAlias = "1B"
if (room=room1C) roomAlias = "1C"
//and so on
//ini_write_real("SaveFile1", "LoadedRoom",roomAlias);
ini_write_string("SaveFile1", "LoadedRoom",roomAlias);
ini_write_real("SaveFile1", "playerx",x);
ini_write_real("SaveFile1", "playery",y);
ini_close();
}
Code:
if file_exists("save.ini")
{
ini_open("save.ini");
LoadedRoom=room_1A; //default room
roomAlias=ini_read_string("SaveFile1", "LoadedRoom", "1A");
//rooms
if (roomAlias=="1A") LoadedRoom = room1A
if (roomAlias=="1B") LoadedRoom = room1B
if (roomAlias=="2A") LoadedRoom = room2A
//and so on
playerx=ini_read_real("SaveFile1", "playerx", 10);
playery=ini_read_real("SaveFile1", "playery", 10);
ini_close();
instance_create(playerx, playery, obj_player);
room_goto(LoadedRoom);
}
else
{
//do nothing
}
---------------------------------------------------------------------
Also, is there a way to change my script so that the loaded game makes player starts in the ENTRANCE of the room where he respawns after he dies? Because each room has a very specific starting point established in a room change object.
For example: If I have to go to a room, player needs to touch a door object with this code:
Code:
//go thru the door
instance_create(x,y,obj_fade)
if (room_exists(other.new_room)) {
room_goto(other.new_room);
x = other.new_x;
y= other.new_y;
spawnx = other.new_x;
spawny = other.new_y;
}
Code:
new_room = room1B;
new_x = 34
new_y = 185
spawnx = other.new_x;
spawny = other.new_y;
Any help will be appreciated!