• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML how to save and load the position "x,y" the player?

R

royer14

Guest
Hello, in this question, I am working with ini files, so to save, I use:
Code:
ini_open("sav.ini");
ini_write_real("Posicion","X",obj_player.x);
ini_write_real("Posicion","Y",obj_player.y);
ini_close();
Now I need to clarify that I use a player object and I place it in each room.
So I do not know how to make the same player object, I guess in the
create event
Code:
ini_open("sav.ini");

var p_x = ini_read_real("Posicion","X",obj_player.x);
var p_y = ini_read_real("Posicion","Y",obj_player.y);
ini_close();
x = p_x;  //obj_player
y = p_y; //obj_player
But it turns out that this only works in the first room -> "room_St1",

I have these rooms:
  1. room_St1
  2. room_St2
  3. room_St3
  4. room_St4
I think the coordinates x and y are different in the rooms

 

PlayerOne

Member
Edit: After re-reading you should make a controller object and make it persistent then place the save code in an alarm or user_event function. That way you can execute the code when needed.
 
Last edited:
Top