Attributes in order
IsabelleK
Member, Sous Chef Posts: 2,807
Hi!
I'm making a hot-seat game (4 players on one iPad). At the end of each level, I want to show scores for each player in order (from biggest to smallest). Each player has his own game attribute, which store his scores:
game.Player1Score
game.Player2Score
game.Player3Score
game.Player4Score
and each player has his own game attribute, which shows his current place:
game.Player1Place
game.Player2Place
game.Player3Place
game.Player4Place
Now I need a rule which will check values for each of score attributes, and change place attributes to the right value. For example:
game.Player2Score is the biggest one, so game.Player2Place changes to 1.
game.Player3Score is the second biggest, so game.Player3Place changes to 2.
game.Player1Score is third in order, so game.Player1Place changes to 3.
game.Player4Score is the smallest, so game.Player4Place changes to 4.
I found a way, which checks value of each score attribute, and compares it to other attributes separately. As you can imagine, it's veeery long, and complicated.
So I'm looking for easier way Any ideas?
Thank you
I'm making a hot-seat game (4 players on one iPad). At the end of each level, I want to show scores for each player in order (from biggest to smallest). Each player has his own game attribute, which store his scores:
game.Player1Score
game.Player2Score
game.Player3Score
game.Player4Score
and each player has his own game attribute, which shows his current place:
game.Player1Place
game.Player2Place
game.Player3Place
game.Player4Place
Now I need a rule which will check values for each of score attributes, and change place attributes to the right value. For example:
game.Player2Score is the biggest one, so game.Player2Place changes to 1.
game.Player3Score is the second biggest, so game.Player3Place changes to 2.
game.Player1Score is third in order, so game.Player1Place changes to 3.
game.Player4Score is the smallest, so game.Player4Place changes to 4.
I found a way, which checks value of each score attribute, and compares it to other attributes separately. As you can imagine, it's veeery long, and complicated.
So I'm looking for easier way Any ideas?
Thank you
Best Answer
-
thumbfrenzylabz Posts: 50How about instead of keeping track of which place an individual player is in you instead keep track of who is in first place, 2nd 3rd 4th...
game.1stPlace = max(game.player1Score, game.player2Score.....
oh wait, this just gives you the highest score, without telling you who has it...
I tried using tables... still no luck :P
Answers
I also got @Enri_ "Jump when collide with actor" question solved hehehe
So much work to do on my own game tho... *sigh*
I have 4 real game attributes (one for each player), which store their scores:
game.Player1Score
game.Player2Score
game.Player3Score
game.Player4Score
And 4 real game attributes (one for each place):
game.1stPlace
game.2ndPlace
game.3rdPlace
game.4thPlace
In the scene I have a table (I don't mean GS table, but just a png image with table), with 4 rows. There are 8 actors (2 columns - 1st to show places of each player, and 2nd to show scores of each player).
In the 1st actor I have such rule:
Change attribute game.1stPlace to max(game.Player1Score,game.Player2Score,game.Player3Score,game.Player4Score)
Rule:
If game.1stPlace = game.Player1Score
Display text: 1st Place, color: Red (this is color of this player).
Change attribute game.Player1Score to -1.
Otherwise
If game.1stPlace = game.Player2Score
Display text: 1st Place, color: Blue (this is color of this player).
Change attribute game.Player2Score to -1.
Otherwise
If game.1stPlace = game.Player3Score
Display text: 1st Place, color: Orange (this is color of this player).
Change attribute game.Player3Score to -1.
Otherwise
If game.1stPlace = game.Player4Score
Display text: 1st Place, color: Grey (this is color of this player).
Change attribute game.Player4Score to -1.
-------------
In second actor I have simillar rule, but I run it after 0.01 sec (run to completion). So, it changes game.2ndPlace to max(game.Player1Score,game.Player2Score,game.Player3Score,game.Player4Score), but remeber that the previous max value is now -1, so it's not taken into account.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
By the way, I see that you are only 15 posts shy of 3000. That will be quite a milestone on the forum.
Yes, you did...but I was typing my answer when you submitted yours. I hadn't read yours yet when I submitted mine :P But yeah, you win for speediness hehe