I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: l3agu32 on February 19, 2016, 10:44:43 AM

Title: How to load a changed background inside the room?
Post by: l3agu32 on February 19, 2016, 10:44:43 AM
I'm using game maker studio. In my game I put the option to change the background_index when you're inside the room, but when I load the game pressing R, the original background appears again. I want to know how to save the background changed when saving the game, so that when loading, the background_index changed is what appears instead of the original background.
Title: Re: How to load a changed background inside the room?
Post by: Smartkin on February 19, 2016, 03:20:58 PM
I suggest creating some sort of flag for example "global.BCGchanged". Then change it to 1 when you change background index. After that in the save game script add "global.BCGchanged":

file_bin_write_byte(f,global.BCGchanged)

In load game scrypt(Usually presented as saveExe) assign the previously saved value to the global.BCGchanged:

global.BCGchanged = file_bin_read_byte(f);

Remember to have them at the same position if you save it after global.item[X] then load it at the same position. Idk if it is necessary in Studio since I work in 8.1 but test both in any case.

Then in room Creation Code:

If global.BCGchanged
background_index[0] = (your background index);

If you want to have multiple changes can have it into array.
Hope it worked and good luck making fangames  :atkHappy: