There is a Youtube version of this tutorial you can also watch:
Everybody likes to win. You’re players want to win. This tutorial covers how to program the win conditions of your game. It assumes no prior programming knowledge except the previous Puzzle Script tutorials I have written.
Load the sample project and scroll down to the Win Conditions section of the code. You should see this:
All Target on Crate
The game is won if every target has a crate on it. If you had 3 crates and 2 targets, you would still win the game with only 2 crates on targets. If you swapped it around:
All crate on target
Every single crate would have to be on a target.
You can have one condition, or multiple conditions. For multiple conditions, they all have to be fulfilled. For example, you could have:
All Target on Crate
All Target2 on Crate2
If you have a target and target2 in a level, they both need a crate and crate2 on top of them, respectively. If you have none of the objects required for a specific win condition in a level, for example no target2’s, then the condition is fulfilled automatically.
Different types of Win Conditions
There are several different types of win conditions.
In the case of the above, you win if there are none of that object in the level.
You win if there is at least one of a particular object in the level.
Some Object1 on Object2
You only need at least one of Object1 on Object2.
No Object1 On Object2
This is a reverse of the all target on crate idea. In this case, you want to get all the specified objects off of each other, rather than on to each other. You can also combine as many different types of win conditions as you like with each other.
Experimenting with different win conditions. Try making a game where you win if all of the crates are off of the targets. Or try making a game where you have to destroy all of a particular type of crate, but other pushable crates are in your way.
Follow this blog for more tutorials on Puzzle Script, games development and updates on my projects.