# Thread: Help with Array object

1. ## Help with Array object

Hello!

I'm trying to understand how an array works, but with no success.
I researched several examples here in the forum, but the examples seem to be very advanced.

I'm doing a simple game, I need to save and to load the position of 5 active objects (x and y position) in a 640x480 frame.

Does anyone have a tip that can help me?

I uploaded an example from the editor I'm trying to do.

Many thanks to anyone who can help me understand how it works!

2. There is an extension called the "Save Game Object" that I believe does what you want. I would check it out.

However, an array you use all the time. A single array is like a shelf you could place books on with each book given a number. You could label the books starting with Book 0, Book 1, Book 2 … etc. This is called zero based indexing. OR … You could label the books starting with Book 1, Book 2, Book 3 … etc. This is called one based indexing. Each Book is considered an element of a 1 dimensional array. To have you get a book, I simply tell you the index number.

If you go to a post office and you use a PO Box for your mail, you are looking at a two dimensional array. Rows and Columns. To locate your PO Box you need two index numbers … row number and column number like PO Box 21 meaning row 2 and column 1.

If you order a 24 carton (box) of Coke you are looking at a three dimensional array. Lets say it has 24 cans of Coke with 12 on the bottom and 12 stacked on top in a matrix. Now to locate a specific "Coke can" I would need to tell you the row number, the column, and the depth number (top stack or bottom stack).

Lets say you and I decide to meet at a certain place and time. This is an example of a four dimensional array. For us to meet, I need to give you a latitude number, longitude number, a height number (on top of a mountain or building floor), and a time.

As you see an array use an index(s) to located something. In your case you could create a two dimensional array like a spreadsheet with rows and columns.

The size of the array could be five rows and three columns (Object_Name, X-Coor, Y-Coor). Some arrays will only allow you to store one type of data like all numbers or all strings. Some allow you to store both numbers and strings. Others will accept even more data like pictures, blobs, bits, bytes, files, etc...

You access the data by giving an index. Well that is true in many cases. You need to read the help files and look at the conditions, actions. Anyway hope this helps.

3. Instead of a story, do it like this

Do a write Active position x to array (1,1,0)
Do a write Active position y to array (1,1,1)

Do a write Active position x to array (2,1,0)
Do a write Active position y to array (2,1,1)

etc.
Then at the end Save Array to file

Then just Load Array from file
set Active position x to Array (1,1,0)
set Active position y to Array (1,1,1)

set Active position x to Array (2,1,0)
set Active position y to Array (2,1,1)

etc

4. Thanks for the explanations guys, but I can´t understand. I think I have some limitation with it. I'm trying to write some value in the x position of offset 1 but I can´t read that value in a counter. Anything that I do with array´s does´t work.

5. Then try the "Save Game Object"

6. Here is your file modified, so you get the idea

7. Thanks!!! i will try it!

8. Droberson, the save game object works, but it works more like a save state.
When I close the application, open and give a load, it only loads 1 of the thousands of objects that I used as a qualifier.

Perry, I think I have a problem, I still can´t understand your example file, because he did not worked it himself. I made all the code the way I understood and did a new upload. Please, if it will not disturb you, can you help me out?

Thank you all!

9. not sure what you don't understand.
you said that you wanted to positions saved from the actives (i just grabbed one)
all I did was take the X and Y position from the active and saved it in the array.
Afterwards when you load it, it puts it back on those positions.
It's up to you which actives you want to use.

This is what you wrote "I'm doing a simple game, I need to save and to load the position of 5 active objects (x and y position) in a 640x480 frame."
and I wrote down 1 active for the Array.
You need to add the other 4 or 5 (since i grabbed 1 of those red ones)
That shows you how you need to save the values and load it back in place.

The save state from Droberson is a global save, and nothing else you can do with it.

edit: you try to save a GROUP of actives. you can't do that with 1 x and Y.
you need to make a loop and do it for each one of them. you said first it's for 5 objects.. now it's for 1000's ...

10. I apologize, but I do not speak English and trying to write in this language leaves things a little confusing for me.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•