Haunted Light – Buttons and Menus!

Hello readers! This week I’ve been working on getting buttons into the menus and assign what they are going to do. After creating the button class it felt natural for me to take the task of putting them into the game and it’s menus, since I was the one that, probably and hopefully, knew the most about how they were made and how they work. If you don’t know how the buttons work, I’ll cover it shortly but I recommend you to read my previous post about the class itself. But to explain them simply, they are basically sprites that checks if the mouse is on it or not.

Placing the buttons on the screen, making them clickable and drawing them wasn’t hard, it was just time-consuming. Every button requires around 15 rows of code just to be created, not even assigning a task to it. Might not sound like a lot, and it isn’t a lot of code really, but writing those 15-or-so rows of code for every single button was tiring. I quite quickly realized that copy-pasting the code would have been lots quicker and probably wouldn’t have been as tiring as writing the code manually. But I wanted to make sure I didn’t make any miniscule mistakes when copy-pasting the code that could halt any progress. But that happened anyway, most likely due to me paying less attention to what I was writing since I had written it so many times before. So next time I’ll most likely copy-paste code after I have grasped what it does and how it affect other aspect of the program from writing it manually.

The main menu is pretty much finished, since it was already designed and had been written down in detail about what sprites to use, on what coordinates to places then, down to the pixel, and what they are going to do. The only thing left is to fix the credits-button, its temporary function is to close the program. The options menu isn’t fully completed, I still have to assign the appropriate action to some buttons, and change some sprites from the placeholders that are there right now. What’s also left to add to the options menu is some text, but I don’t expect that’ll take nearly as long as adding the buttons.

The planned placeholders that are currently in use is the arrows on top, the check boxes underneath them and the two buttons on the bottom. The main menu is also showing in the background, that was intentionally left there to show that as well as the options menu, killing two birds with one stone. Otherwise there is a background for the options menu.
Options

The actions of the buttons that may or may not be shown in the screenshot:
A text-only button makes the text glow when the mouse is over it.
The check box toggles showing and hiding the check mark when pressed.
The arrows will be used to change the resolution. A text in between them will show the resolution the game has when you enter the options menu, and will then change based on what arrow is pressed.
The speakers work in a similar way that the arrows do, the one on the left lowers the volume and the one on the right raises it. The volume is shown by the bars in between them, each lit bar represents 10% of the volume.
The “Quit” button in the options menu is a placeholder for the “Back” button, that takes you back to the main menu.
The “Credits” button in the options menu is also a placeholder, this one for the “Apply” button. This applies the changes that were possibly made. Exiting the options menu without applying any possibly changed settings would discard them.

That would be it for this post, don’t want to get any more boring than it got there during the last part. Thank you for reading and I hope you’ll be back for the next post.

Regards
Calle Johansson, Gamedesign and Programming