I am a new student with Udemy studying the Unreal Engine C++ Developer course. My goals are to build a solid foundation from which to grow into specific areas of development with the Unreal Engine as a content production platform, while developing versatility that would allow me to utilize the engine in many different ways. I have a good foundation of knowledge of programming in a variety of languages and am looking to solidify those skills with more theory and practical applications for the skills I’ll be learning. I’m really looking forward to the challenge and opportunity for creativity this course offers.
Chapter 13 (Unreal Engine C++ Developer 2022)
The purpose of the main function in any C/C++ program is that it is the starting point of the program (in the form of a Portable Executable (*.exe) on Windows). This is the point that execution begins when it is first run from the Windows GUI or the command line. When the application is run, the Windows OS looks up the address offset location of the main function in the .exe file and runs the machine code from there on one of the CPU cores of the system. This behaviour is the same for all compiled executables targeted as a .exe file format output during compilation and builds of custom and library code.
In the case of the application we’re developing, TripleX, it is:
-
the point from which we first declare and initialize all of the variables we’ll be using during the program
-
the point from which we communicate with the end user via the standard console device via std::cout device stream and accept input via the standard console device via std::cin device stream
-
the application loop is also contained in the main function, where it simply loops continuously until certain circumstances are met with the values of variables that may be altered by the end user via their input.
-
If during the application loop these values indicate that the end user has progressed through the required number of questions, they win and are presented with a winning message and then exit gracefully
-
Alternately, if any of the questions are answered incorrectly, the application with break out of the loop and present a message to the end user that they lost the game and then exit gracefully
-
During the application loop, the end user’s answers are checked as to whether they match both the sum and the product of the real answers to the question generated randomly within the game loop
-
During the generation of each question, the current round number is added to the range of random numbers that determine the answers, hence with each round, the possible answer becomes more difficult
-
The application loop also ensures that the syntax of the end user input is correct and in the case it isn’t, it re-asks for that input until the end user inputs the correct syntax, at which point the input is verified as to whether it is the correct answer or not