How do i create a speed order

0 favourites
  • 8 posts
From the Asset Store
Awardkit
$5 USD
Create custom awards and achievement or use the many templates and create your own.
  • First, I want to be able to input a player name and a speed for the character.

    Then the enemy's speed is randomly generated.

    Then have the order sorted by the speed of each character.

    This dictates when it is each characters turn.

    Just so you know I have tried to use an array. I don't seem to understand the concept behind them, much less how to use them correctly. If someone can help me understand how to use an array, that would be very helpful. Thank you.

  • Are you trying to achieve something like RPG battle speed such as FInal fantasy ten ?. If so it sound like you need to get some math geek to do it.

  • You can see arrays as a collection of lists, depending on the amount of dimensions there are in it.

    For instant a 1 dimensional array is just like a list or if you imagine making 5 variables named:

    X0, X1, X2, X3, X4

    So instead of referring to each variables name like:

    Set X0 = A

    Set X1 = B

    etc.

    You can use an array, which have an index number instead, so imagine you have an array called X:

    X: [0],[1],[2],[3],[4]

    Then you could assign values like so:

    Set X[0] = A

    Set X[1] = B

    etc.

    The benefit is that you can store lots of data in an array, without having to create all the variables. And you can go through the array with a loop, for instant:

    For I=0 to 4

    Set X = <some value>

    A 2 dimensional array, is like an excel document.

    A-----B-----C

    0-----0-----0

    1-----1-----1

    2-----2-----2

    So to explain that you can imagine that this array we use for storing enemies, so each of the letters would be an enemy.

    and for instant row 0 could be the health of the enemy, row 1 the XP you gain from killing it and row 2 whether it can fly or not.

    So this way you can store a lot of enemies in an array, and get the data from it. For instant say you need Enemy (C) and you need its health.

    So explained simply, you could do "Get C(0)".

    3 dimensional array, I don't think is all that common. But to explain it, imagine you have a grid based map of 100x100 tiles. And in this map there are a Ground level, Water level and Air level, which would be the 3rd dimension, and the array would be called X,Y,Z and the 3rd dimension is the Z.

    So to explain it.

    The X dimension is the tile position in X direction

    The Y dimension is the tile position in y direction.

    Z is the depth of each tile, in this example it would be 2, since it starts at index 0,1,2. (Water, Ground, Air)

    So imagine you wanted to store a flying unit of some sort in the array at position X,Y (10,10), but also a ground unit as well.

    Then you could store the flying unit at:

    X,Y,Z (10,10, 2)

    And the ground unit at:

    X,Y,Z (10,10, 1)

    So basically that's how you can think of the different arrays and dimensions.

  • Thank you both for replying and the array makes sense now. But can I sort both columns only using the column for speed? If so can someone explain that process

  • Lordshiva1948

    Thank you for the links, as I now have an understanding of what to do. i really appreciate all of the help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • jaekaido most welcome. We are here to help any time

  • Okay, now when i sort my array, it displays 10 as less than 1, not greater than nine. What do i do?

    EDIT: I have found a way around it, but still would like to know what i did wrong?

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