Posted By
|
Message
|
Dave S.
Registered 26/09/2003
Points 924
|
31st December, 2006 at 08:49:55 -
I am in the process of making a level editor for a game and need to know the easiest way of saving all the active objects on a particular game level once edited. This has to include the background which is made up of only one 64 x 64 pixel block but has been cut and pasted many times. I have tried the 'Save Game' extension but couldn't quite understand it... happy new year to you all!
n/a
|
Radix hot for teacher
Registered 01/10/2003
Points 3139
|
31st December, 2006 at 09:39:19 -
Arrays are great, and come with a save-to-file function. The specifics really depend on how your editor works. If the maps are grid-based, set the value at each (X,Y) cell of the grid to a value representing the tile at that location, and use the Z axis as well if multiple objects occupy the same square.
If the maps aren't grid-based, I'd still use arrays but it depends exactly what you're doing and I've been drinking and I can't be arsed explaining any more right now.
n/a
|
Dave S.
Registered 26/09/2003
Points 924
|
31st December, 2006 at 17:37:30 -
I've never used arrays before as they look a little complicated.
Has anyone used the 'Save game' extension before?
Thanks for your comments Radox (is that something you put in the bath?), Dave.
n/a
|
axel Crazy?
Registered 05/02/2005
Points 4766
|
31st December, 2006 at 19:28:41 -
Arrays waste a lot of space just to save a few numbers. If you're semi-leet you could load directly from normal text files (list object, etc), with some string manipulation/parsing. It'd make them more hackable though, but you could always encrypt them or something.
n/a
|
Radix hot for teacher
Registered 01/10/2003
Points 3139
|
1st January, 2007 at 03:55:27 -
Arrays waste a lot of space just to save a few numbers.
Only if you're fucking retarded about it. If the bulk of your indices aren't being used, then you've designed it wrong anyway. If they are being used as they should be, then it's a relatively efficient way of doing things.
n/a
|
Werbad
Registered 18/09/2002
Points 235
|
1st January, 2007 at 06:36:07 -
Axel is right on this point. If i remember correctly, the array uses 4-byte values, meaning that you can store values from -2147483648 to 2147483647 (I think). If you only need to store low values, a byte-array would be better. And a string is a sort of byte array...
n/a
|
Radix hot for teacher
Registered 01/10/2003
Points 3139
|
1st January, 2007 at 18:38:44 -
Please to be directing your attention the the original poster. He asked what the "easiest way" was.
Dave S., use the search link on your left to look for articles about arrays. They aren't particularly difficult, and you needn't worry about the file size unless your levels are fairly big.
But this all depends on an answer you still haven't given yet. Is your editor grid-based, or not? If not, there's a better way.
n/a
|
Dave S.
Registered 26/09/2003
Points 924
|
2nd January, 2007 at 17:39:37 -
... yes it is grid based. I thought there may have been a quick way of saving the entire screen of objects and their locations in one instance like an initiation file but without the hassle.
n/a
|
Dave S.
Registered 26/09/2003
Points 924
|
12th January, 2007 at 14:11:00 -
Radix... I did a search like you said but none of them explained the array extension that well so was wondering if you could give me a short example... say there are two objects (64 x 64 pixels), one located at 0,64 and one underneath... how exactly would I set that up as an array? If it's lots of lines of code or instructions then don't worry... thanks, Dave.
BTW there are around 40 objects to save on each level.
n/a
|
Billybobjoe198
Registered 12/01/2007
Points 221
|
12th January, 2007 at 16:01:35 -
This comes up so often here....
n/a
|
Tim I'm on here way too much
Registered 25/08/2006
Points 132
|
12th January, 2007 at 20:03:15 -
*-2147483647 to 2147483648
Sounds more likely to me... since 8bit = -127 to 128
http://www.SilverNova.co.uk
|
Radix hot for teacher
Registered 01/10/2003
Points 3139
|
12th January, 2007 at 20:38:01 -
No, to say you have 8 bits allocated describes nothing about how they're used. You could use it to store -127 to 128, or -128 to 127, or 0 to 255.
-128 to 127 is ordinary two's compliment and you'll find it's more common than -127 to 128.
Dave S.:
I'm going try to explain this in the simplest terms. This isn't the BEST way to do this, but don't worry about making your storage more efficient until you understand how it works.
An array, if you didn't know, is a basic multidimensional data structure for storing values. You can think of it as a vector of vectors. A vector is a series of indicies (say, 0-4) that can store values. So the value at index (1) might be "356" and the value at index (3) might be "11111112" or whatever. Put two of them together and you have an array ranging from index coordinates (0,0) through (4,4). You can keep addind dimensions, but the array object only allows for three (unless you do some fancy stuff, but forget about that for now).
So to use your example:
say there are two objects (64 x 64 pixels), one located at 0,64 and one underneath... how exactly would I set that up as an array?
Okay, first of all make your 3-dimensional array object, set the sizes of the X and Y dimensions to the number of squares in your grid and the Z dimension to the number of 'layers' it's possible to stack objects on (let's say only 2, so you'd need Z size 1), and make sure it's 0-based (otherwise your indices start at 1 and you don't want that).
Next, by dividing the locations by the size of the grid intervals you get their location on the grid. So (0,64) becomes (0,1). That's where we'll store it in the array. So store an arbitrary ID value for one object at (0,1,0) and the other object at (0,1,1).
To make it easy, you can use fastloop and an object to sort of walk over all the tiles and fill in the array (taking advantage of overlapping for MMF's object focus).
I'm not going to explain it any better than that so play with the array object a bit and look at articles if you still don't understand. Note that when you start adding to the size of the third dimension your file size is going to go up drastically. Personally I avoid this by using a 1-dimensional array and concatenating values together in a single index, but that's not something I feel like explaining either.
n/a
|
Tim I'm on here way too much
Registered 25/08/2006
Points 132
|
12th January, 2007 at 20:39:59 -
ok? my bad..
http://www.SilverNova.co.uk
|
Radix hot for teacher
Registered 01/10/2003
Points 3139
|
12th January, 2007 at 20:44:13 -
There are three dots in an ellipsis.
n/a
|
Chrisbo
Registered 02/01/2002
Points 794
|
12th January, 2007 at 23:48:50 -
I use fastloops. I've only made grid based savegames, so if yours isn't grid based, sorry. The save and load routines are like 5 events each, then a series of "if then" type events to create the objects once loaded. If you are interested, I will whip up a little demo and email it to you. Let me know.
Chris
hay
|
Chrisbo
Registered 02/01/2002
Points 794
|
12th January, 2007 at 23:49:27 -
btw my editors I've made use standard text files to store the levels. I use the edit object to save and load.
hay
|
Chrisbo
Registered 02/01/2002
Points 794
|
12th January, 2007 at 23:51:51 -
also, I think radix is like 1000x above my level of programming these things, but my editors are still pretty decent and they kick ass for what I need them for
hay
|
Chrisbo
Registered 02/01/2002
Points 794
|
12th January, 2007 at 23:54:47 -
oh hell maybe I'll just upload something for everyone to see
hay
|
Tim I'm on here way too much
Registered 25/08/2006
Points 132
|
13th January, 2007 at 08:24:31 -
Wow, quadruple post! A rarity these days
It wasn't an ellipsis, it was two fullstops.
http://www.SilverNova.co.uk
|
Dave S.
Registered 26/09/2003
Points 924
|
13th January, 2007 at 09:13:11 -
Radix... I've just had a quick read of your last post. I will print it out so that I can fully understand it... looks interesting though... thanks mate.
Chrisbo... my game is grid based (actually a remake)... the fastloop save and load rountines sound good too and I would certainly be interested in those... cheers.
n/a
|
Billybobjoe198
Registered 12/01/2007
Points 221
|
13th January, 2007 at 09:43:38 -
Dave S. O.O Thats a little freaky....Are you who I think you are?
n/a
|
Dave S.
Registered 26/09/2003
Points 924
|
13th January, 2007 at 15:47:01 -
Bobjoe... who do you think I am then?
n/a
|
Billybobjoe198
Registered 12/01/2007
Points 221
|
13th January, 2007 at 16:56:41 -
I was wrong.. your... your....I was going around the internet with nuklear not to long ago saying to people "HEY wow hi it's me dave, Dave S from elemetry school remember?"
n/a
|
Chrisbo
Registered 02/01/2002
Points 794
|
14th January, 2007 at 03:35:15 -
what are you using? I can give you pre-MMF2 using fastloop or MMF2 with the built in fastloops.
hay
|
Dave S.
Registered 26/09/2003
Points 924
|
14th January, 2007 at 04:51:54 -
Chrisbo... I am using MMF 1.5 build 119... did somebody mention fastloops... that's another thing I've never understood how to use properly... is there any hope for me?
n/a
|
DaVince This fool just HAD to have a custom rating
Registered 04/09/2004
Points 7998
|
14th January, 2007 at 10:23:49 -
Fastloops just loop a certain action very quickly for a set amount of times.
On event > start fastloop "blah" 10 times.
On loop "blah" > do an action that would run 10 times very VERY quickly (in about one frame).
Old member (~2004-2007).
|
|
|