I am making a 4 player couch co-op fighting game. Everything was going great until I got to the win conditions.
Since each player can choose: red team, blue team, or solo.
I am stumped on how to create the win condition....
I feel like arrays will be the answer some how. Just not sure on the logic....
Choose character, choose team. Fight.
Players die off.
Now how do I detect which players are victorious?
Note, I am using the Health add-on
related Player instance variables
Health; collective team health; team choice
Teams: Red, Blue, Solo P1, Solo P2, Solo P3, Solo P4
Teams can be:
2 v 1 v 1
1 v 1
1 v 1 v 1
1 v 1 v 1 v 1
As you can see, there are a lot of possible combinations.... so logic is required to sort it all out.
Please advise on the logic :)
Faux code is appreciated.
I consider myself an advanced user.
Loads of ways to do it. I would do it by having 2 global variables and instance variables on the characters for red/blue which you already have. When they pick red add 1 to red global var, or blue add 1 to blue global var. When character dies check their team, compare if its red then subtract 1 from red global var. If red or blue = 0 then the other team wins. You can also use picked count of players with red/blue instance var and use that to compare if greater than 0. The logic applies to any of those combinations given because it's just counting R v R v B or B v B v R, doesn't really matter.
Develop games in your browser. Powerful, performant & highly capable.
Nice, I see where you are going with this.