Phase 1…Commencing in 3.2.1…

Frankie Rodriguez
3 min readDec 12, 2020

Thanks to the coursework teachings and the guidance from the GameDevHQ community, and of course, Doctor Professor Google, I finally made it to phase one. Now that I have a greater understanding of the foundations of coding, I feel confident that I will be able to push forward and complete the assignments. Today, I tackled increased movement of the player. I coded it so whenever I press a key DOWN, the player movement increase, BUT, as soon as that button is let go, the player movement returns to its’ normal speed. The button I used is the LEFT SHIFT. To accomplish this, I used codes I have already implemented in my game, i.e. using the space bar to fire player lasers. I then researched further on Google to further understand how the GetKey, GetKeyUp, GetKeyDown codes function differently and to determine what code would function to my needs. I finally determined that the GetKey code made the most sense, however, that didn’t stop me from testing all three. Trials and tribulations are the essence of coding. When I determined the right code that would serve my needs, I researched how to increase my speed when the LEFT SHIFT button was pressed down. This was done referencing the speed power up code. Here is how I executed my code — transform.translate(direction * _speed * _speedMultipler * Time.deltatime); Even though I determined which GetKey code would work best for me, I tested all 3 methods, just in case. The GetKeyDown (tap, tap, tap, tap……) gave me small short bursts of speed. This function only stays true for the small moments the button is tapped down. The GetKeyUp worked the same way, however, the speed would increase when the button is let go.

Short bursts of speed.

The GetKey allowed for increased speed in the player movement when I held down the button (LEFT SHIFT DOWN = BOOOOOOOSTER POOOOWER!!!!). Check mark on task 1 of phase one.

With a small win in my pocket, I moved on. Before moving on to the next task, I wanted to ‘zoom out’ the main camera to increase the game scene. Of course, like with anything, you can’t change one thing and expect the rest of your code to follow suit. When I ran the game as is, it was obvious where the boundaries of the game where prior to me ‘zooming out’. Enemy spawned in weird positions; enemy fire would disappear before hitting the edge of the scene; power ups would spawn in weird positions. It was a mess.

Pay attention to the spawn points of the gameObjects.

To fix this, I needed to adjust the x, y spawn/respawn positions of the enemies, enemy lasers, the player, and of course the power ups. I also needed to adjust the destroy methods for the gameobjects. There was a moment of panic prior to realizing what I needed to do, but with the knowledge I had, I ran the game and knew everything would work out.

--

--