Day 13 with GameDevHQ

Eric Hankins
3 min readDec 20, 2020

“Survival can be summed up in three words — Never give up. That’s the heart of it really. Just keep trying” -Bear Grylls

Today I started to explore the “C# Survival Guide”. Right out of the gate, the aspect of understanding coding became a little clearer. Throughout the 2D development course we were introduced to a handful of variables, data types, if-statements, loops, arrays, coroutines, etc… I need to be honest here, I really did not understand everything 100%. I simply followed along, and then replayed the section over and over until I successfully accomplished the task at hand. By the end of it, I did retain a bit of understanding as far as logic goes. However, I felt it would be impossible to explain it. Albert Einstein said, “if you can’t explain it simply, you don’t understand it enough”. So here is my attempt at explaining each section of the C# Survival guide thus far.

As a project manager, I had to remain acute of all variables that can come my way when fulfilling a project. When organizing logistics, people, time, and deadlines, anything can happen that forces us to go against our original plan. It takes quick thinking, and quick reacting. So when I hear the word “variable”, I think I have a great understanding of what it could mean. However, in coding, “variable” means something slightly different. It’s more like a box, that contains information (or code) neatly packed away. There are 4 main variables we use in C# coding: int, float, bool, string. An int can represent a number that doesn’t have a decimal point. For instance, we can use an int variable when assigning a score. A float is used when needing a number that has a decimal point; for instance, speed works best when your number includes decimals. Giving a smoother “launch” requires incrementally smaller digits. A bool or Boolean, is a statement that can be either true or false. So, for instance, if you want to create a cap on your speed, you will use a bool. “isTopSpeedReached = false;” would allow us to assign an cap within the code. “isTopSpeedReached = true;” then “speed = x”. Coding like this would mean that the top speed is reached. This is utilized more often in “if” statements. I’ll explain that in the next paragraph. A “string” is simply a phrase or words. This would allow us to write a whole paragraph in one section, then quickly copy it within the use of one variable.

If Statements were utilized a lot in our 2D Development course. To explain “if” statements simply, its best to think about the logic and what you’re trying to accomplish. When you come to the point of “If I do this, then this needs to happen”. That is when you utilize an “if” statement. So to elaborate on the example above, “isTopSpeedReached”, you can use something like this: “if(speed >= x (desired top speed) {“isTopSpeedReached = true; speed = x}. This is pretty much saying, “if speed is at assigned speed cap, then speed wont increase past the top speed”. This, in short, assigns a speed cap which is of course necessary; otherwise our player may increase speed until the end of time. If statements are also important for assigning an action when a key is pressed. “if(Input.GetKeyDown(KeyCode.Space)” is an example of the code required to take an action when a key is pressed. So in this example, we can increase speed when “space” is pushed down by adding { speed += 10 }.

I’ll be continuing the survival guide, hopefully until the end, before going back to 2D development. It’s a lot to do, but I feel a greater understanding of C# coding will make the challenges for Phase 1 and 2 a lot easier, and cleaner. I may go back through the 2D development course, staying persistent to accomplish all the challenges; while also accomplishing the relevant challenges along the way. Looking forward to continuing on this journey of understand logic.

--

--