This week we have had a lot of things to do since final is closing in. Most of the tasks this week has been buggfixes and implementing all animations to make the game more smooth and fun to play. But one thing that I have worked a lot with besides these tasks is the Endstate of our game.
The Endstate is the state when the player either loses or wins the game. The easiest one of these two were the lose critera. When the players stress has reached its maximum amount the player dies and the game is over. Stress represents the players health. So this part was actually quite simple. The win critera however, was anything but simple. I had this vision in my head where the player wins and the locomotive appears and when the player passes the locomotive the player has won. It might sound simple when put like this, but it really was not.
There are some thing that I need to clarify before I can explain further. We have two trains which we loop since our game is a sidescroller. Basically we draw two trains after eachother and loop them when they go out of screenbounds to create the illusion of a long running train. These are constantly drawn out and looped as the game is running. So, what I wanted to do was to draw the locomotive as soon as the player picks upp the last owlet from the train (owlets needs to be picked up to win the game). And when this occured I also wanted to replace one of the trains with the locomotive and stop drawing that train. And this should only happen if the last owlet was picked up aswell as the second train was fully visible on the screen. I chose this solution beacuse I wanted to create a smooth transition.
To do this I made a boolean variable that checked if the last owlet was picked up and change it to true. And if this boolean variable was true aswell as the position of the second train was equal or less to zero in the x-axis the locomotive was to be drawn out and the other train stopped being drawn. And when the second train was out of screenbounds it also stopped being looped and drawn out. And finally when the locomotive was out of screenbounds the player has won! I worked many hours trying to accomplish this and now it works as I wanted it to. I am very pleased with the outcome!