What's the use of an array?

0 favourites
  • 6 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Can someone give me an example of a practical use for an array in a game?

  • I advise you to check the tutorial 'arrays for beginners'.

    It doesn't explain everything about arrays, but does cover a whole lot!

    Good luck!

  • Arrays are group of variables. You can use array to make for example high score for each level .

  • Can someone give me an example of a practical use for an array in a game?

    Arrays are probably the single most powerful construct in any programming language, including C2. The following are just trivial examples.

    A 1D (1 dimensional) array can store (and allow you to easily retrieve) a list of numbers or text.

    A 2D array is like a grid and so is good at storing, e.g. a level full of things that you can easily access via x,y coordinates.

    3D arrays are useful but less common IMO, you might use them to extend your 2D levels to have floors as well

    They are powerful because you can go through them in a 'loop', rather than one by one. Or grab one randomly by its 'index'

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You use arrays when you want to store multiple variables and variables relating to those variables. This makes it great for things like Level editors where each enemy or object can have its name stored in X and all of the information about it stored in the Y's (it's position, angle, starting health, animation, or whatever you want). I also use arrays for dynamic lists like in multiplayer by using them to determine which player is trying to send a chat message to whom. it works with just X values and uses position 0 for the senders name, position 1 for reciever, and position 3 for the message.

    The sky is the limit for how complex their use can become, but in general, they are for large sums of data handling or dynamic lists.

  • Thanks all your answers were very explicative!

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