DSDN 142: Project 3
I chose to show the idea of the if/else statement with the use of a simple game called “the Maze”. The objective of the game is to reach the end of each maze. In the game there are three mazes and the only way to exit each maze is to turn on the switches in that level. This is where I try to show the idea of the if/else statement. Also you cannot touch the wall or enemies, something that does not show the if/else statement as obviously, but makes the game more interesting and keep people more interested. Although it still does show the use of the if/else statement: if player touches wall or enemy, game over equals true, else they can keep playing.
The use of switches:
if(switch is on){
exit turns green
You can exit
}
else{
exit is red
you cant exit
}
In the first two levels this is the basic use of if/else. But in the last level there are three switches which show a more complex use of this statement. There are three moving blocks that block the exit that move too fast for the player to get through. But if the player turns on all the switches, the enemies slow down and the player can exit the level.
Enemy1 speed equals 3 and player can pass
Else{
Enemy1 speed equals 10 and player cant pass
Switch 1 is red
}
When all three switches have been activated, the player can exit.
If(all switches are on){
Player can pass enemies and exit
}
Else{
Player cant exit
}
This is how I tried to show how an if/else statement works. If a switch is on you can go, if not, you can’t. This is similar to traffic lights, something that everyone is familiar with and hopefully everyone one will be able to understand the if/else statement with the use of my game.