I Have A Quick Array Question

Get help using Construct 2

Post » Thu Nov 14, 2013 2:20 am

Would it be better for me to use multiple array grids for each layout that i have?
The reason i ask is because i have 4 biomes that will each hold different ores underground.
I understand how to place and set them through arrays but what i dont understand is would it be better for me to use different array grids for each biome or would it be benificial to use the same array for all the block tiles in the game?
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Thu Nov 14, 2013 2:34 am

I would think using a single array would be best and just change the X coordinate to reference the biome or what-not. Multiple arrays mean more objects being loaded.

I tend to use a single array and set the dimensions and references as needed without any noticeable drop in performance... unless you're talking 100s of dimensions.

Maybe the memory management of C2 and arrays works differently, so I'm just guessing.

Alternatively, you could use a single array, store the array in the Dictionary, and clear the array for a new biome.
B
16
S
6
G
2
Posts: 152
Reputation: 3,764

Post » Thu Nov 14, 2013 2:42 am

@Space Ape Is there any Tutorials of any kind to show me how to clear an array and reuse it.
And if i do use it that way wouldnt it erase my previous data for the biome i last visited?
Thank you for your reply.Now i just need to learn how to reuse arrays.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Thu Nov 14, 2013 4:21 am

There is no real disadvantage in using one array per biome. They use the same amount of RAM as one multi-dimensional array (apart from a little negligible overhead), they are accessed at the same speed, they are loaded when needed (when changing layout) so the loading process is a few ms faster and you might feel more comfortable with seperate arrays.

Copying an array to a dictionary and clearing it for a new biome (and copying it back to the array when needed) will be the slowest and most expensive solution. I wouldn't recommend it.
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Thu Nov 14, 2013 12:22 pm

@tulamide Thank you for your expert OP.
I would of maybe ruined my project if i had went the other route.

Two questions i want to ask is how would i keep my world loaded once it loads for the first time through arrays?
if they are loaded when needed how would i save the current state of the array every time i leave the layout?RookieDev2013-11-14 12:22:56
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Thu Nov 14, 2013 12:47 pm

I am very sorry that I contributed to your confusion. On default, every array added to a project is set to global. So just ignore that sentence and instead add the arrays to your project on the first layout, and they will be available throughout the whole game.
Unless you want to load them per layout. Then you'd adding them on their respective layouts and set the global property to "no".
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Sat Nov 16, 2013 5:45 am

@RookieDev - tulamide is undoubtedly correct; however, I was offering clearing the array as an alternative, not the best, method. I'd recommend just using one array and use the X coordinate of the array to determine which biome you're in. If forests are 1 and jungles 2, then 1, Y, Z is wide open for anything to do with that biome... use X as an index to tell the game which biome to use, then just switch that variable (such as a global variable) to tell the array to read a different X.

Either way, best of luck, amigo.
B
16
S
6
G
2
Posts: 152
Reputation: 3,764


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests