Page 1 of 1

Saving and loading using arrays and tiles Please Help someon

PostPosted: Fri Jan 29, 2010 8:18 pm
by Hblade
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 ^.^

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

PostPosted: Tue Feb 02, 2010 5:33 am
by Bee-Ant
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 ???

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

PostPosted: Tue Feb 02, 2010 5:42 pm
by Hblade
Thanks, BeeAnt :3

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

PostPosted: Tue Feb 02, 2010 6:40 pm
by Bee-Ant
Your welcome.
Still confused?
i have the demo.

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

PostPosted: Tue Feb 02, 2010 8:08 pm
by Hblade
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

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

PostPosted: Sun Feb 07, 2010 5:27 am
by Bee-Ant
YW :D

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

PostPosted: Sun Feb 07, 2010 7:06 pm
by Hblade
hehe :D I understand arrays now :3

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

PostPosted: Mon Feb 08, 2010 12:56 am
by Bee-Ant
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.

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

PostPosted: Mon Feb 08, 2010 1:45 am
by Hblade
k thanks :D