How do i create a speed order

Get help using Construct 2

Post » Sat Feb 14, 2015 7:39 pm

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.
B
5
Posts: 9
Reputation: 243

Post » Sun Feb 15, 2015 4:00 am

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.
B
51
S
24
G
6
Posts: 391
Reputation: 7,808

Post » Sun Feb 15, 2015 4:21 am

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[I] = <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.
B
41
S
10
G
2
Posts: 1,159
Reputation: 6,542

Post » Sun Feb 15, 2015 6:19 am

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
B
5
Posts: 9
Reputation: 243


Post » Sun Feb 15, 2015 4:02 pm

@Lordshiva1948

Thank you for the links, as I now have an understanding of what to do. i really appreciate all of the help.
B
5
Posts: 9
Reputation: 243

Post » Sun Feb 15, 2015 4:06 pm

jaekaido most welcome. We are here to help any time
B
212
S
29
G
14
Posts: 1,866
Reputation: 36,941

Post » Tue Feb 17, 2015 4:22 am

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?
B
5
Posts: 9
Reputation: 243


Return to How do I....?

Who is online

Users browsing this forum: hyem and 29 guests