How do I properly insert a value in the array in this case

Get help using Construct 2

Post » Fri Dec 19, 2014 10:03 pm

When the subject is array I just stuck. I'm trying for hours jsut to do a simple thing and I hope someone could help me on this.

I have a simple 2,3 Array and here is the logic:

I need to insert an UID always at X=0 and a value at X=1. So the array would be like this:

UID | Value
114 | 1
116 | 2
123 | 4

When I add the first UID in first line I need to stop the insert action. Also I need to compare if the UID match. If so add 1 to the Value.

The way I know right now, it would insert in all lines because when it runs in the first time everything is empty (aka 0) so it'd always replicate the first line.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sat Dec 20, 2014 12:22 am

Anyone?
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sat Dec 20, 2014 12:59 am

It might sound clear to you but it's not really. This is how you insert.

Array: Set value at (0,0) to Sprite.UID
Array: Set value at (1,0) to 4 (or whatever)

Unfortunately we can't see the proprties of your array
We don't know why you are storing UID (maybe you're doing something wrong there). You should store some "ID" value IMO
"I need to stop the insert action" What does this mean?
"I need to compare if the UID match" Match what?
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Dec 20, 2014 2:50 am

@codah

My game is sort of a bowling game. You have to shoot at a cetain distance, pass trough all obstacles and try to take down all pins that are far enough from each other.
One of the bonuses that I will calculate to the final score is that if the player take down more than one pin with the same ball, it add a number that I will store and use to multiply his score.

Example:
Ball1 hit pin whatever.
Ball2 hit pin whatever
Ball2 hit another pin whatever.
... in this moment I need to check if it happened and how many times took down after the first pin. So, one extra pin (after the first) means a value that will affect the score, two extra pins another value and so on.

Edit: The reason that I'm trying to store UID's Ball is that I need this information to compare how many times the same ball hit and took down a number of pins.

Edit: to simplify, I need to know how many pins I took down with one ball. Knowing this, I only need to subtract 1 to know all the extra pins.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612


Return to How do I....?

Who is online

Users browsing this forum: dop2000, jatin1726, nahima and 4 guests