Using Arrays For Player Turns

Get help using Construct 2

Post » Fri Feb 22, 2013 9:51 pm

Hey guys!

I have been working on a project that is sort of an interactive power point presentation in construct 2. That aside I have been using arrays to see how many players are playing.

Once all players are documented in the array the game goes to the layouts based on the array. Like if player 1 is playing go to layout player 1. So if there is only 3 players playing then it would skip player 4. I hope this makes sense.

The real question i guess is how do i insert players into the array and loop through the array to get to player 2, player 3, and player 4.

Thanks,
Constructdude
B
22
S
5
G
3
Posts: 194
Reputation: 5,855

Post » Fri Feb 22, 2013 11:30 pm

Manual Entry for Arrays

You would first use push to push each player into the array's back, putting them in the order you want. To find out who the current player is, you look at the first element. When it's time to move to the next player, you're push the first element to the back, then pop the first element (removing it) thus making the 2nd element the 1st.

push 1
Array(1)
push 2
Array(1,2)
push 3
Array(1, 2, 3)
push 1
Array(1, 2, 3, 1)
pop 1
Array(2, 3, 1)

etc...
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Fri Feb 22, 2013 11:37 pm

Thanks

I wasn't thinking XD, got it too work. :D
B
22
S
5
G
3
Posts: 194
Reputation: 5,855


Return to How do I....?

Who is online

Users browsing this forum: YoHoho and 12 guests