When level conditions aren't met..
gottakeepgamingon
Member, PRO Posts: 8
Hey there, GS people! New member here (very new -first post, too) and I'm in need of a little help. I've searched the forums and can't find anything that answers this.
Okay, I'm making a game where there's a 'domino effect' thing going on. You get only one click. On mouse click I spawn an actor with a timer that destroys itself eventually. It collides with others in the scene (and they destroy themselves over some time, as well) and when so many are killed, you move onto the next scene. All of that is worked out, but my problem is when the objective isn't met.
For example, you need to kill 5 actors in level 1 to move onto level 2. If, however, you only kill 4 and they destroy themselves from the screen and cannot create a domino effect to kill others …what then? How do I tell it to stop the game and allow me to insert a retry button or screen or something like that?
Thanks in advance for any help!
Okay, I'm making a game where there's a 'domino effect' thing going on. You get only one click. On mouse click I spawn an actor with a timer that destroys itself eventually. It collides with others in the scene (and they destroy themselves over some time, as well) and when so many are killed, you move onto the next scene. All of that is worked out, but my problem is when the objective isn't met.
For example, you need to kill 5 actors in level 1 to move onto level 2. If, however, you only kill 4 and they destroy themselves from the screen and cannot create a domino effect to kill others …what then? How do I tell it to stop the game and allow me to insert a retry button or screen or something like that?
Thanks in advance for any help!
Comments
In the enemy actor, add a change attribute behavior at the top of the rules but not inside of a rule and change game.enemyCount (an integer) to game.enemyCount + 1. Also add a change attribute behavior right above the Destroy behavior and change game.enemyCount to game.enemyCount - 1.
For the lose condition, add an After 0.1 seconds timer not inside of a rule and then place a rule inside of the timer with the condition When attribute game.enemyCount = 0 ... [change scene or whatever behaviors you want to run when the player loses].
The timer is needed because when the scene starts, game.enemyCount is 0 by default. After the enemies increase it, then the lose condition can check its value.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Not sure I understand. If I add 1 to the game.enemyCount, then also before the destroy subtract 1 from the game.enemyCount, what's changing?
Maybe I should explain that these actors aren't spawning in the scene, the scene starts with a fixed number of guys running around. Say, 7 guys. In order to move to the next scene, you need to bump into and kill 5 of them. As it stands now, kill 5 or more and we move ahead and things are good. If we kill 4, the game won't end. The guys just wander around forever.
I feel like I need an if/then type of thing. Like IF the domino chain ends and there are less than the required amount killed, THEN retry or whatever. I have a counter that counts them off as they die. It seems to hinge on that last guy dying, and when I put it to a timer, it either ends too quickly or else it waits around forever. Is there any way to check the last dead guy and then check the if/thens of it all?
Anyway …I'll keep plugging away and hopefully some of you big GS heads will know!
Always appreciative!
I assume you're going to have a timer. Otherwise, how will the level ever end? So let's say that after 30 seconds if you haven't killed at least 5 enemies then you lose. Forget what I said about the count. Remove those rules/behaviors if you added them. Instead, before an enemy is destroyed, add one to game.enemiesKilled (integer). Have a rule that says when game.enemiesKilled >= 5 then change scene. Have a separate rule that has two conditions (set to when ALL conditions are true instead of when ANY are true): self.Time >= 30 and game.enemiesKilled < 5 then change scene to Lose scene.
You just have to keep track of the number of enemies you killed and check that value after the time expires.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Okay, that works! Sweet!
It's a little bit clunky in the way that it works, but I think that I just need to tighten up things on my end a little. Play with the time, etc. Much better than what I had going on -thanks!
Much appreciated!