Day 14 — Framework completed

Today was a very productive and satisfying day working on my game. I edited several sections of my script to more directly apply the parameters of the speed boost functionality. I achieved the desired effect by revising the calculate movement method of the player script, in that when the user presses the desired key (left shift, in this case), the bool for speed boost is turned to true.

I combined this if statement with a parameter that a variable called thrust be greater than zero; if so, the player gets the speed boost via a new method. In that new method, the thrust amount is depleted at a rate determined by a variable, which is easy for the programmer to edit to preference. When this variable reaches zero, or the user depressed the left shift key, the thrust amount slowly rebuilds to full. I preferred the ratio of 20:5 — that is, each second of time with the key pressed depletes 20% of the boost (5 seconds from full to zero), and each second of time refills the boost by 5% (20 seconds from zero to full). I used mathf.clamp (super useful) on the thrust variable to keep it between zero and 100.

nice and clean
reduction and fill variables are set in the header of the script

I finally managed to figure out a way to implement the visual representation of the thrust amount on the UI as well, today. Basically, I started by creating an image shaped as a narrow rectangle, sized to my liking, eventually adding a slider component. Then I added two more children to that, representing the border and the fill. Essentially, when the variable is “full,” the fill layer image covers the border. As the variable decreases, the size of the fill overlay decreases, showing the border image below, and giving the effect that the gauge is decreasing. By adding the slider component to the parent, I was able to indicate which image I wanted to represent the fill, and therefore change with the script.

using a method to change the slider value

I ended up liking this implementation so much that I went back and added a very similar aspect to the laser ammunition. With the laser, however, I passed an integer into the method, rather than a float — so that the player has exactly fifteen shots and the slider indicates that. To do this, I simply had to create two public Sliders: sliderThrust and sliderAmmo.

I wrapped up today by tinkering with the visual representation of the UI on the screen — I’m not sure exactly where I want each element to be during gameplay. There are trade offs between visibility and avoiding cluttering the screen and/or blocking gameplay. I’ll also be tinkering with some more of the post processing effects.

Lastly, I again adjusted some of the powerup script. Now, if the player collects powerups while that targeted area is “full,” the player gains ten points (the same value of destroying an enemy). Since this is done by passing an integer through the method, it will be easy to adjust the value later if needed. For example, if the player already has a shield active and collects another shield powerup, the player will gain ten points. Similarly, if the player has a full thrust boost and collects a speed powerup, the player will gain ten points.

I’m feeling very good about my progress today. I was able to rough outline what I wanted to do and chip through each facet methodically. I’m very excited for the Core Programming section!

Coding my future as a software developer; // if (attitude > 0) {progress ++;}