Git KEY(S). Thrusting away from my problems.

It’s day 5 (actually day 10 of the program itself) of my internship to become a fully employable software developer and engineer. Most times in life, I like to tackle any problems I have head on, don’t let it have time to fester and frustrate. Give it some focus and get it knocked out, you know the drill. But today, today wasn’t one of those days.

Git GONE.

The day actually started off with a 45 minute trouble shooting effort to try and resolve my issues with the GitHub. No dice. Even with assistance, the program seemed to have latched on to one of my larger files, and hung on to it for dear life. I attempted some solo problem solving, but the efforts seemed fruitless. No matter what solution I tried, nothing seemed to work, and the threat of having my entire project reset, or lost loomed, as it had just happened to one of the other interns also having issues with the platform.

Welcome to GitHub, may I take your order? ME: I’ll take a number 5, with a large NOPE.

So, with a large sigh, I decided to move on to greener pastures, and I actually learned something I’m confident enough to share today. So, I learned how to implement a thrust system into the space shooter video game I recently made! The challenge was as follows:

  • Move the player at an increased rate when the ‘Left Shift’ key is pressed down. Reset back to normal speed when the ‘Left Shift’ key is released.

I had actually attempted to tackle this problem the day before, over complicating the issue by making private bool terms and a verbose amount of code trying to describe what I wanted the game to do when ‘Left Shift’ was held down. After some coffee and a short break from the Get Rek’d Hub, I researched how the input of keys worked in C#.

Interestingly enough there were a few choices for simple key inputs the main ones as follows:

  • GetKeyDown
  • GetKeyUp
  • GetKey

Now, from a first look, which command would you think that the solution would require to create a function that fulfilled the statement in the challenge? I had initially thought, GetKeyDown. But actually, the GetKeyDown senses when a key is pressed, and executes the exact moment the key is pushed down. GetKey would be the correct answer in this instance!

Whoo, learning!

GetKey is as I ascertained, when the key is “present” perhaps, “being pressed” would be a more accurate description.

What a Cat-astrophe!

Armed with my new knowledge, I set out to write a code to create that increased speed, which turned out to be much more simple than I imagined. By a simple if/else statement, I was able to create a relatively skinny code that actually worked the FIRST time I tested it!

_thisIsAwesome == true;

Ignore my little comment about communicating with the UI, I placed that there for a future implementation that I knew would be coming along in the near future. But yeah, I was able to tackle this problem relatively quickly, and it perked up my whole day! In the end, we were able to find a workaround to the GitHub issue, however, in the end I was right, today was definitely a better day. And I came out of it with some…

…Key knowledge.

Remember, murder is technically illegal.

Ambitious Software Engineer at GameDevHQ.