Coding Recap – 16/10/20

What is a Variable and how have I used one?

A variable is part of a code that stores information, this could be a players name, a number, a bool (true or false). As in the screenshot above, I have a few string variables. Other variables would be an integer which is a whole number, a float which is a number to a decimal point, a string of text.

What is a Class and how have I used one?

A Class in code-terms is something that hold information that can be reused easily. Essentially encapsulating data and behaviour. This is also useful when it comes to organising code so all of your code isn’t just in one giant script. In this example, I created a separate class for navigation. This can then be called in another script by using “Navigation.NorthFromStart()” as an example… although that would result in death for this game.

What is a Function and how have I used one?

A function is something within a class that holds a block of code and the function can be called at various points. In this example I have a Class called GameOverExit which is called in the main program numerous times, when someone fails to choose the right option, the main program will call this Function.

This will turn the console colour red, print some text and then wait for a button press to close the console down.

What is an If Statement and how have I used one?

An If Statement is something in code that can output different options dependent on certain conditions and//or requirements. In my example, if the requirement of player name being God is met, they will be granted a cheat code you would only know if you typed in God for your name. Otherwise, it wouldn’t tell you the cheat code.

The hardest part of making my game was starting it off, I couldn’t quite get my head around how to take the user’s input and then make the computer read it and store it, but looking at it now, its deceptively simple. The part I am most proud of is all the different functions I have used and how they have been able to affect the outcome of certain scenarios.

I would love to learn how to implement a bool system and make the game check to see if that bool is set to true, just to enable or reinforce certain aspects. Take a weapon for example, if the bool is set to true for that weapon, then the user can use it, if not, it calls the function again for a different option.

Just for referencing purpose, my game can be downloaded at this blog post. LINK.

Leave a comment