Welcome to the first post in my Dev diary! I have absolutely zero experience when it comes to coding or making games, so this might be a little slow. This will be a series of blog posts outlining my development as a coder. Highlighting my successes, (many) failures and issues I come across during my time at Portsmouth University!
Today was our first in depth coding studio workshop. The software we are using is Microsoft Visual Studio Community 2022 for learning C++ and also Unreal Engine's Blueprint system. We created a console application in Visual Studio Community. The system seemed rather overwhelming at first, but when I took my time and went at my own pace, it wasn't as bad as it seemed.
The session today was a workshop, so we have instructions to follow, which then have additional questions to help test what we learned, which can get a little tricky at first. As it's only an introduction to the C++ language, we are only currently messing around with variables which isn't too complex. I did however, branch off on my own and discover how to use functions!
I learned that you can use something called a namespace to simplify your code. Below you can see that I've declared the the standard (std) namespace. You do this at the top of the project.
Without the namespace implemented, this is what the code would look like:
If I use the namespace std (standard) it will look like this:
As you can see the length of the code has shortened! It might not seem like much, but it made my life easier when typing out a lot of lines and having to remember all the symbols and stuff to put in between your commands. Having knowledge of these namespaces will save time when it comes to writing code in the future. Especially for deadline based projects, such as our Game Jams which have tight deadlines. Namespaces are also useful due to different headers having various other similarly named functions. So the code will now assume that I want to use the std format unless told otherwise.
As I'm a complete beginner when it comes to coding, I learned about each function in a line of code and how to include different data types into my code.
Below you can see two functions I made to run during the workshop.
During our workshop I learned about creating functions, these are basically a set of instructions that fall under a simple name and are declared in C++ with the following code: void *insert whatever name you like* () {enter instructions}
Functions can be used to avoid rewriting the same lines of code multiple times. You can minimise these functions to keep your screen neat and tidy and then call them back to work in a different sequence of code by typing out the functions name followed by () and then a semi-colon to end the line. In line 42 you can see that I declared a new variable. I just used float, but you can use any type of variable and then named both created functions to play out in the console window.
In the future I can use functions to shorten the length of my code and save on development time. However, so far I don't know if you're able to edit instances of functions depending on when and where you're calling upon the function. So this will be something I have to look into in the future.
Did you like this post? Tell us