Secret door (Optional)ΒΆ
You can use the moves mechanics for other things as well.
Lets add a secret door that opens when you reach a specific location.
You need the following steps to happen:
check if the player has reached the location opening the secret door
replace a wall by a floor tile
create a move of a wall tile
Implement all of this at the end of the move_player() function.
Complete the following code:
if game.x == ... and ...:
game.level[3][2] = "." # wall in row 4 column 3
move = Move(tile="wall",
...
)
Note
At the moment, the location of the secret door and the trigger are hardcoded. To make the mechanics more generic (e.g. to have multiple secret doors), you will need the dictionary data structure. Dictionaries will be introduced in the chapter Teleporters.