Can I copy objects? Or how to do multiplayer

  • I?ve got a question about copying objects as if they were variables.

    I?m making a turn based card game with 4 players (hotseat game). Each player is represented as an Object with a number of attributes (CardsInHand, Score etc.).

    When Events happen in the game I need to update one of the players attributes depending on whose turn it is. So something like this

    Player1

    Player2

    Player3

    Player4

    <turn 1>

    CurrentPlayer = Player1

    <then play the turn>

    Add 1 to CurrentPlayer score

    Add a card to the CurrentPlayer hand

    Etc.

    <turn 2>

    CurrentPlayer = Player2

    What?s the best way to accomplish this while keeping the code as simple as possible?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Give the Player object an instance var called 'playerNumber' and set it to 1, 2, 3, 4 on each of your players. Have a global var called 'currentPlayer'. And then you simply do:

    Player: playerNumber = currentPlayer

          Player: Add 1 to score

  • Ah thanks ramones that looks to work fine.

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