Destruction Productions

Make Games. Make Money. Make Friends.
HomeRegisterLog in

Share | 

 Save the current level

Go down 


Number of posts : 252
Registration date : 2009-05-06
Age : 25
Location : Stockholm, Sweden

PostSubject: Save the current level   Sun Nov 15, 2009 5:50 pm

It doesn't have to be more advanced than this, execute_file() isn't so slow that it can't be used and the file size really doesn't matter much, it probably won't be bigger than 5 kB.

 var i, j, object_number, object, file, str, n;
 //object_number=the number of different objects to be saved
 //here specify which objects are going to be saved
 str="var i;";
 for(i=0; i < object_number; i += 1)
    for(j=0; j < instance_number(object[i]); j += 1)
        n=instance_find(object[0], j);
        str += "i=instance_create(" + string(object[i]) + ", " + string(n.x) + ", " + string(n.y) + ");"
        + "i.other_variable=" + string(n.other_variable) + ";";
        //The other_variable is whatever else we want to save for this instance,
        //a if(object[i] == obj_enemy)save this variable else don't save it.
 file_text_write_string(file, str);

and the result for my sample level:

var i;i=instance_create(1, 176, 48);i.other_variable=3.65;i=instance_create(1, 96, 208);i.other_variable=0.54;i=instance_create(1, 240, 240);i.other_variable=3.44;i=instance_create(2, 176, 48);i.other_variable=3.65;i=instance_create(2, 96, 208);i.other_variable=0.54;

then it's just to execute the file when we want this new level to be loaded.

My band's MySpace
My deviant art
Back to top Go down

Number of posts : 919
Registration date : 2009-02-21
Age : 26
Location : Helsinki, Finland

PostSubject: Re: Save the current level   Sun Nov 15, 2009 6:06 pm

Well done. So now we just need a level editor, which cant be really done yet.

WTF = Welcome To Finland

"I'm a Finnish man. I eat iron and sh*t chains!"
Back to top Go down


Number of posts : 296
Registration date : 2009-02-25
Location : Illinois

PostSubject: Re: Save the current level   Tue Nov 17, 2009 3:47 am

Very good, I'm glad to see you contributing Gulesnuffs, keep up the fine work! Very Happy

Watch Awesome Videos!!
Back to top Go down
Sponsored content

PostSubject: Re: Save the current level   

Back to top Go down
Save the current level
Back to top 
Page 1 of 1
 Similar topics
» Current trading pattern of GREG
» What is the best bank /banks to open a current account?
» What are the reasons for current dull market ??
» HVA will reach 60 level by tomorrow................
» What are the reasons for the current market collapse?

Permissions in this forum:You cannot reply to topics in this forum
Destruction Productions :: Archives-
Jump to: