Saving and loading using arrays and tiles Please Help someon

Non-platform specific questions.

Saving and loading using arrays and tiles Please Help someon

Postby Hblade » Fri Jan 29, 2010 8:18 pm

Okay, I've tried asking this kidna thing before, and I've obtained some GED files that were confusing I would just... LOVE ta know how the heck to create tiles, (or clones) of one object, then save it's x and y position for the next time you load it? Almost like a level editor but not quite. I can make such an awesome game this way :O But thats a secret ^.^
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Saving and loading using arrays and tiles Please Help someon

Postby Bee-Ant » Tue Feb 02, 2010 5:33 am

This can be done with cloning...

The method should be :
-> Create the map
-> Save each tiles infos (x,y,animation) into arrays

FIrst, make the array variables.
TileX, TileY, TileAnimpos
The size should be the total size of the map size. If your map size 20x20, then the array size should be 400.
TileX[400], TileY[400], TileAnimpos[400]

When in Creating Map Mode :
-) Map=>Create Actor=>ScriptEditor :
Code: Select all
TileX[cloneindex]=x;
TileY[cloneindex]=y;
TileAnimpos[cloneindex]=animpos;
//cloneindex would point the current actor clone index
//you can view that index number by the Actor's name on Actor Control Panel
//Actor.0 Actor.1 Actor.2 etc

Your tile's clone number must be under 400. Or else your array would be out of bounds.

To save Map infos :
-) Simply :
Code: Select all
saveVars("data.dat","variablegroup");
//I don't need explain this


To generate maps next time you load the game :
-) Make a function to do this :
Code: Select all
void LoadMap()
{
    int i;
    loadVars("data.dat","variablegroup");
    for(i=0;i<400;i++)
    {
        CreateActor("Map","MapTiles",TileX[i],TileY[i],true);
        Map.animpos=TileAnimpos[i];
    }
}

-) Map=>CreateActor=>ScriptEditor :
Code: Select all
ChangeAnimationDirection("Event Actor",STOPPED);
//crucial code for tiles

Any question ???
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Saving and loading using arrays and tiles Please Help someon

Postby Hblade » Tue Feb 02, 2010 5:42 pm

Thanks, BeeAnt :3
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Saving and loading using arrays and tiles Please Help someon

Postby Bee-Ant » Tue Feb 02, 2010 6:40 pm

Your welcome.
Still confused?
i have the demo.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Saving and loading using arrays and tiles Please Help someon

Postby Hblade » Tue Feb 02, 2010 8:08 pm

Nah I wont be confused by reading this :D Cause you explained it ^.^ It's the demos that confuse me more sometimes lol... But only when the demo is by DST :P
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Saving and loading using arrays and tiles Please Help someon

Postby Bee-Ant » Sun Feb 07, 2010 5:27 am

YW :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Saving and loading using arrays and tiles Please Help someon

Postby Hblade » Sun Feb 07, 2010 7:06 pm

hehe :D I understand arrays now :3
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Saving and loading using arrays and tiles Please Help someon

Postby Bee-Ant » Mon Feb 08, 2010 12:56 am

Glad to hear it :D
I just knew array since WB2 development anyway. Not so long ago.
My advice, dont use array over 500 for 1 dimensional array, and over 75x75 for 2 dimensional array. It will lag your game much, or even make it stopped working.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Saving and loading using arrays and tiles Please Help someon

Postby Hblade » Mon Feb 08, 2010 1:45 am

k thanks :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron