How do I chose an array to configure a level.

0 favourites
  • 8 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi everybody.

    I have a group of array. Each one has index with the "difficulty configuration" for each level of my game.

    Example :

    LEVEL 01
    index 0 difficulty 1
    index 1 difficulty 2
    index 2 difficulty 2
    LEVEL 02
    index 0 difficulty 2
    index 1 difficulty 2
    index 2 difficulty 3

    I want to access each array with a variable. Because I need to setup difficulty when my player is upgrading. So I want to use my variable, "playerGrade".

    At the start of the game, this variable is set to 0.

    When the player makes an upgrade this variable set 0+1.

    Currently I don't know how to access an array by a variable. Please help me ^^

    Tagged:

  • Im not sure I understand what you need, but you can easily access arays using variables by using the variable as parameter for the Array.At() function.

    For instance:

    Let's say I have an array with levels and their titles and rewards.

    [

    ["Welcome Level!", 10],

    ["Adventure Time", 25],

    ["Find the Treasure", 60],

    ["Trouble Ahead", 130],

    ["Final Battle", 270]

    ]

    And a variable level that controls which level the player is.

    Array.At(level, 0) would return the title for the current level.

    Array.At(level, 1) would return the coins earned for finishing the current level.

    So, when players are in level 0, they'll return thet title "Welcome Level!" and the reward 10 coins.

    Hope this helps.

    Cheers!

  • Now... If you want to use a variable to determine which array to access I'm not sure this is possible. But you could use a JSON or a Xml object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks brunopalermo

    In fact, I'm working on a procedural system for levels creations.

    So I have a group of arrays. Each one contains the configuration of the game. When the player is upgrading, I have to change my game configuration. And so, I have to use the next array.

    And I really don't know if it's possible to access my "levelArray01" when my "playerGrade" is 1 and my "levelarray02" when "playerGrade" is 2.

  • I don't think it's possible... Why don't you use a JSON? It can store several arrays and all level configurations you want or need. :)

  • brunopalermo Arf, you're right. ^^

    Currently, I don't know how to use json, but I'll probably have to learn.

  • Umm, would a 3 dimensional array work?

    Array.at(index0,difficulty1,level3)

  • Maybe a three dimensional array will do. I'm not aware of how complex is his array structure.

    In case you need to use JSON. Check this entry at the manual, which is very straightforward and has a link for a working project that will really help you understand. If you still have trouble, just ask here. I've been using JSON for some time now and I'd be happy to help you.

    Cheers!

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