I Have A Quick Array Question

  • 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?

  • 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.

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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".

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)