Help with winning condition
Hi, brand new here. I'm making my first game, and I've reached a stopping point. If this is the wrong place to post this question, let me know.
In each level of my game, there are a mixture of good guys and bad guys who all appear onscreen at the same time. The objective is to destroy all the bad guys and leave all the good guys. I have figured out how to destroy the bad guys and how to end the game if a good guy is accidentally destroyed.
What I haven't figured out is how to direct the program to know when the winning condition has been met. I want it trigger a "Congrats!" message and "Go to next level" link when the correct actors are left.
If this cry for help isn't clear enough, imagine a level having 10 actors. Let's say actors 1 and 2 are the good guys and actors 3-10 all need to be destroyed. The winning condition is if 1 and 2 are left and all the others are destroyed, then the player completes the level. How do I give the program these instructions? Would that be game attributes?
Thanks for the help!
Comments
You found the right place.
In the "bad guy" actor, Change Attribute game.enemyCount to game.enemyCount+1. This will quickly sum the number of enemies. If you have 14 enemies, game.enemyCount will be 14. Have a rule that says If [however you choose to destroy enemies] then Change Attribute game.enemyCount to game.enemyCount-1.
The win condition should be If attribute game.enemyCount≤0 then Display Text or Change Scene or whatever you prefer. Be sure to place this rule inside of an after 0.1 seconds Timer. Otherwise, it may trigger when the scene starts (because game.enemyCount is initially 0).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Wow! Thanks for the quick reply. I will try this tomorrow after work! Thanks so much!