My game, made in GameMaker, consists of various rooms (levels) through which you go on progress. So, imagine I'm on level 7, and I leave the game, it goes back to room 1. Also, the only thing I have to save is just the level I'm in, I don't want to keep any coins or else!

Does anyone know how to stop and save the game and go back to it later on? I'm programming using the built-in GML scripting language.

Thank you so much in advance.


1 Answer 1


Games are applications, and application data in memory is non-persistent. Then, if you want to keep using previously seen data, you must first save it somewhere. Regardless of file format, compression, encoding, encryption... You are saving information on a device for subsequent retrieval.

A simple way to store the level you're currently in is via INI files. They allow you to store small pieces of information and retrieve them later using key-value pairs.

Let's say your game is designed (i.e. you want it to) to open a file named progress.ini, which is an INI file located in the game's working directory. You can, for example, create such a file dynamically (if it doesn't exist yet) when the game starts via the Game Start Event, and it will be saved where your game can access it.

Then, a simple implementation would be as follows:

  • When the game starts, try to open the file progress.ini and read the value saved in the key last_level in the section [levels].
    • If the value exists: update the internal game variable for the current level, and make the game continue from that room.
    • If the value OR the section OR the file doesn't exist: use a default value ("level 1" or similar), and update the internal game variable for the current level. The game will continue from that level (which, coincidentally, is the first level of your game).
  • Every time the player progresses through the game (e.g. at the end of a level, before the next starts), save the current level index in an INI file named progress.ini (the same name as the file we loaded before) so that the level progress will persist even if the game closes unexpectedly.
  • \$\begingroup\$ i have two doubts. Where do I find the ini file? Also I have this code, my question is: where do I put this code? ini_open("savedata.ini"); . score = ini_read_real("save1", "score", 0 ); . ini_close(); Im sorry, im new to gamemaker :) \$\endgroup\$
    – T14Seara
    Jun 18, 2023 at 10:06
  • \$\begingroup\$ I updated my answer to address your questions. TLDR: you create the file because it's not there yet. Execute ini_read_*() on game launch so you can load the level before the actual game loads. \$\endgroup\$
    – liggiorgio
    Jun 19, 2023 at 11:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .