D
Dengar
Guest
im creating a buffer save/load system that saves sprites and variables to a single external file.
below is what I have sofar. its just doing variables and it works
but how do I handle sprites? I understand I have to draw sprites to a surface and use buffer_get_surface and buffer_set_surface somehow. also ive read that I can only put 1 surface in a buffer? so im guessing I must draw all my sprites to the surface?
and I think my final issue is there will be an unknown number of variables and sprites that ill be adding/reading from the buffer, how does that work, im guessing I can somehow detect how many values are in the buffer and then simply loop through the buffer that many times and read them?
below is what I have sofar. its just doing variables and it works
but how do I handle sprites? I understand I have to draw sprites to a surface and use buffer_get_surface and buffer_set_surface somehow. also ive read that I can only put 1 surface in a buffer? so im guessing I must draw all my sprites to the surface?
and I think my final issue is there will be an unknown number of variables and sprites that ill be adding/reading from the buffer, how does that work, im guessing I can somehow detect how many values are in the buffer and then simply loop through the buffer that many times and read them?
Code:
///save
var f;
f = get_save_filename("play_data|*.pldat", "");
if f != ""
{
buff = buffer_create(16384, buffer_grow, 2);
buffer_write(buff, buffer_string, "vari 1");
buffer_write(buff, buffer_string, "vari 2");
buffer_write(buff, buffer_string, "vari 3");
buffer_save(buff, f);
buffer_delete(buff);
}
Code:
///load
var f;
f = get_open_filename("play_data|*.pldat", "");
if f != ""
{
buff = buffer_load(f);
var cmd = buffer_read(buff, buffer_string );
show_message(cmd);
var cmdd = buffer_read(buff, buffer_string );
show_message(cmdd);
var cmddd = buffer_read(buff, buffer_string );
show_message(cmddd);
buffer_delete(buff);
}
Last edited by a moderator: