Not a whole lot has gotten done this week. This tends to happen when I don't have a Thursday off. I will be working on game related things tomorrow, but I felt like making a blog post today.

The current task that I've decided to work on is volume control for the music in-game. This has made me realize that I had a screwed up scheme for producing the music.

I have already implemented the sound controls into the title menu. Now I need to put it in the in-game menu. It shouldn't be too hard, I just need to put a little time into moving around the current menu objects and creating a new sub-state for the menu.

I also need to create a feedback response to selecting the volume control. Something as simple as a slight change of text or selection arrow color would be fine. I'll probably try the arrow first since changing text color in one menu and not in others will probably seem a bit off.

An interesting thing about the volume control; Since I decided to use a slider, I was able to reuse an art asset that I already had; The clash bar. The volume control was relatively easy to match up with the visualization of the slider. Since volume is measured from 0 to 1 and the slider bar is not a pixel width of 100, I had to create a formula that detected where the slider was. The code is short and simple.

First, the 325 is how far the bar's left hand edge is from the origin of the sprite. The word "Music" is included in the sprite. That's why this isn't just 0.

obj_sound.audio_level is multiplied by 100 due to the audio level being a decimal between 0 and 1. This converts it into a whole number.

The audio level then being multiplied by 4.55 is directly related to the sprite width. The left and right hand points on the bar that I wanted the slider to stop are 455 pixels apart. That means that each percent of volume is equal to 4.55 pixels.

The following is the code in the PlayerStats object. This object is persistent and holds much of the game's important information.

Very simple. Has volume change been enabled? Does the sound object exist? (I had to add this even though the sound object is persistent due to a strange crash that noted that obj_sound could not be found) If these are true and you are pushing a certain direction on the thumbstick, change the level by 1%. Also, don't allow the sound to exceed its limits of 0 and 1.

Since the slider position is connected to the obj_sound.audio_level value, it will always show an accurate position. Pretty neato.

I plan on squaring this away tomorrow and will probably start on either AI fixes or more art. It all depends on what sounds more fun tomorrow.