Week 6, Pause Function

This weeks topic might be a simple and boring one since it’s only about the pause function of our game. However, I figured there might be some solutions to how things were done that might be a tad interesting so bare with me for a bit.

A pause function is probably not necessary in such a small game like ours but it’s mainly there to not force the player to die if in need of a unplanned toilet break or just need time to rest and regain some focus. This is how I solved it.
The update function in our game state class which you could say takes care of the in-game-loop is quite slimmed down and basically just calls for all our game’s different managers. This allowed me to easily implement a boolean check before running the mentioned updates.
If this pause bool was FALSE: run the updates.
If the pause bool was TRUE: don’t run the updates and instead present the pause menu on top of the game area. The pause menu only covered a smaller part of the game screen so I also added a grey rectangle with low opacity to give a greater sense of that the game play was actually inactive.
The buttons for the pause menu was created with the help of a struct that held a text for the button and an integer to serve as the button index. Each button was created in a loop which looped through a set amount of times for as many buttons that was needed and added to a vector array. At the moment we only needed two buttons (a Continue and a Quit button) which may have made the loop a bit unnecessary but it will make the implementation of further buttons easier in the future.
Maybe I also should mention that these buttons wouldn’t be clickable with the mouse but only accessed with a keyboard. An integer in the game state class was compared to the index in of the respective buttons as the user pressed the up and down arrows and adjusted the color of the current matching value to show which button that was selected. It would then perform the assigned task to the specific value when the activate button was pressed which in this case would be the return key.
See, this wasn’t that boring at all, was it?
Thanks for reading!pausemenu

Week 6, Pause Function

One thought on “Week 6, Pause Function

  1. PDLC says:

    Hello Marcus!

    Your blog was indeed very interesting. You first go through the structure of your code by mentioning your loop and what it does. When mentioning the Boolean checks you successfully explain how using if-statements you check if the value of the bool is true or not in which telling the game to stop updating and in effect pause the game. I think that explaining logical thinking to an audience of readers helps a lot of people to dismantle and structure problems they are in so to make it easier to solve by their own. This I think you do very well.

    You display a healthy forethought in your programming as well. This I know is very valuable when you sometimes don’t know what you will need in the future. You explain how an integer was assigned to the respective up and down buttons to tell the player when a button is ready to be activated by the return key. This is a solution that fits the pause menu that you have implemented but earlier in the blog you say that if you wanted you could implement more buttons in the future. It would have been good if you included an explanation where how to check which button is active only using the arrow keys. As you said, these aren’t difficult problems but it would have been interesting to see how you would’ve handled it.

    Many thanks Peter

    Like

Leave a comment