Today I started using Visual Studio Code which is a new IDE I have never used before. Unlike Clion, it does need a little bit of extra work in order for the program to run.
After creating the file TripleX.cpp and wrote the code, I will have to right-click on the file and choose to open the integrated terminal and then type:
g++ TripleX.cpp -o triplex //this is for compiling the file using G++ on MacOS.
./triplex //this is for running the program.
Another way is to literally install an extension called run code and then I can press F1 to open all comments and search for run code and then run it.
Another way I somehow found out by myself is to press Run on the menu and choose Run without debugging and choose G++ as the config tool.
I still do not understand what is clang, g++, and LLVM is but I will probably have to look up these things in the future and to figure it out. I guess they are the kind of tool to help with compilation.
#include <iostream>
Today I learned #include is called preprocessor directive. Basically, they are instruction to the compiler and we use it to include a library before compiling. We always put this at the beginning of our program to tell the compile that we will be using this. <iostream> is the header. It is instructing the compiler to copy the contents of the iostream header file into our code before the rest of our code is compiled.
Naming Conventions in Unreal Engine
- The first letter of each word in a name is capitalized and is usually no underscore between words. For example, Health and UPrimitiveConponent. But not dealta_coordinates or lastMouseCoordinates.
- The standard is here.
- You can select code and use CTRL + / to make these code comments.
Seeding rand()
Somehow our game produce same result by rand() every time we run it. In order to have a different result we need to seed our rand by using computer’s time.
#include <ctime> //allow us to get access to computer’s time
srand(time(NULL)); //this creates random sequence based on the time of the day