Book Image

Learning C++ by creating games with UE4

By : William Sherif
Book Image

Learning C++ by creating games with UE4

By: William Sherif

Overview of this book

Table of Contents (19 chapters)
Learning C++ by Creating Games with UE4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Variables and Memory
Index

What is building and compiling?


You might have heard of a computer process term called compiling. Compiling is the process of converting your C++ program into code that can run on a CPU. Building your source code means the same thing as compiling it.

See, your source code.cpp file will not actually run on a computer. It has to be compiled first for it to run.

This is the whole point of using Microsoft Visual Studio Express or Xcode. Visual Studio and Xcode are both compilers. You can write C++ source code in any text-editing program—even in Notepad. But you need a compiler to run it on your machine.

Every operating system typically has one or more C++ compilers that can compile C++ code to run on that platform. On Windows, you have Visual Studio and Intel C++ Studio compiler. On Mac, there is Xcode, and on all of Windows, Mac, and Linux, there is the GNU Compiler Collection (GCC).

The same C++ code that we write (Source) can be compiled using different compilers for different operating systems, and in theory, they should produce the same result. The ability to compile the same code on different platforms is called portability. In general, portability is a good thing.

Scripting

There is another class of programming languages called scripting languages. These include languages such as PHP, Python, and ActionScript. Scripted languages are not compiled—for JavaScript, PHP, and ActionScript, there is no compilation step. Rather, they are interpreted from the source as the program is run. The good thing about scripting languages is that they are usually platform-independent from the first go, because interpreters are very carefully designed to be platform-independent.

Exercise – ASCII art

Game programmers love ASCII art. You can draw a picture using only characters. Here's an example of an ASCII art maze:

cout << "****************" << endl;
cout << "*............*.*" << endl;
cout << "*.*.*******..*.*" << endl;
cout << "*.*.*..........*" << endl;
cout << "*.*.*.**********" << endl;
cout << "***.***........*" << endl;

Construct your own maze in C++ code or draw a picture using characters.