Create player objects, assign player number, assign player color, class, etc.

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I am trying to do the following but having a hard time know what to search in the forums and online when it comes to terms. Some guidance would be massively appreciated.

    My first screen determines how many players will be playing the game. So I ask, how many players. This is a board game that can have upwards of 10 players.

    So let's say they would like to choose 3 players. I would then like to create 3 instances of the player object AND assign them each a player number via an instance variable called PlayerNumber. Or... I don't have to create the player object yet.

    The other thought I had was gather all the information about the player before creating the player object as the following screen I need to have the player make a few choices about their character. They need to choose a class, game piece color, etc.

    When the # of players is selected on the first screen, say 3 players in this case, would it be better to create an array that has a row for each player. Then as they choose class, piece color, etc. we would fill the array? Then finally when the game starts we would create a player object that represents their game on the board with the selected color, etc.?

    If that is the better direction how do I create an array on the fly and set the rows to how many players there are from the variable.

    So the array would maybe be something like this...

    Player Number Name Class Color
    1 Joe hunter red
    2 Dave mage green
    3 Sarah ninja orange

    I would then fill each of the array spots with their choices. Then once we load the game board I would need to be able to create the pieces based on their choice during the setup screens.

    If you can direct me to the best tutorials on how to go about this or provide guidance of let me know what you need for me to gain my answers I would be mega appreciative. Thanks for your time spent! Means a lot!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sounds like you have the right idea. I wouldn't say there was a tutorial for this except where the manual guides you through making a simple array. The best way would be to give each player an ID as mentioned and that ID relates to the row in the array, so player 1 is always x = 1 which is array.at(1,?) and then the Y is the values you mentioned. Because you know there are limited number of players you can setup the rows beforehand. You could even add data dynamically while they are choosing a class for example, if they are assigned player 1, as they select class the array.at(1,1) would update to reflect their class but that might not be entirely necessary. Then once you are in the level you use a for loop to run through each row and create each piece in turn with one event so create object name array.at(loopindex,0), class array.at(loopindex,1) and colour array.at(loopindex,2), that works for all players.

  • Not sure what you're trying to do, but this file may help.

    Cheers!

  • brunopalermo I can't dive into the file until later but at first glance this is amazing and probably will get me quite a ways down the path. Can't wait to study it more and learn from what you have shared. REALLY appreciate you sharing that. Once I have had the time to look it through I will definitely come back and let you know how it went. Thanks so much!

    Really appreciate your time as well. I am going to read through what you shared as well and see how I can apply. Thanks for spending time to respond! Great community as always.

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