Using Arrays For Player Turns

0 favourites
  • 3 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • 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 <img src="smileys/smiley36.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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...

  • Thanks

    I wasn't thinking XD, got it too work. :D

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