Learning C++ by Creating Games with UE4
eBook - ePub

Learning C++ by Creating Games with UE4

William Sherif

Share book
  1. 342 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning C++ by Creating Games with UE4

William Sherif

Book details
Book preview
Table of contents
Citations

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning C++ by Creating Games with UE4 an online PDF/ePUB?
Yes, you can access Learning C++ by Creating Games with UE4 by William Sherif in PDF and/or ePUB format, as well as other popular books in Informatik & Objektorientierte Programmierung. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781784396572

Learning C++ by Creating Games with UE4


Table of Contents

Learning C++ by Creating Games with UE4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What is a game engine anyway?
What will using UE4 cost me?
Why don't I just program my own engine and save the 5 percent?
A game's overview – the Play-Reward-Growth loop
Monetization
Why C++
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Coding with C++
Setting up our project
Using Microsoft Visual C++ on Windows
Using XCode on a Mac
Creating your first C++ program
Semicolons
Handling errors
Warnings
What is building and compiling?
Scripting
Exercise – ASCII art
Summary
2. Variables and Memory
Variables
Declaring variables – touching the silicon
Reading and writing to your reserved spot in memory
Numbers are everything
More on variables
Math in C++
Exercises
Generalized variable syntax
Primitive types
Object types
Exercise – Player
Solution
Pointers
What can pointers do?
Address of operator &
The Null pointers
cin
printf()
Exercise
Solution
Summary
3. If, Else, and Switch
Branching
Controlling the flow of your program
The == operator
Coding if statements
Coding else statements
Testing for inequalities using other comparison operators (>, >=, <, <=, and !=)
Using logical operators
The Not (!) operator
Exercises
Solution
The And (&&) operator
The Or (||) operator
Our first example with Unreal Engine
Exercise
Solution
Branching code in more than two ways
The else if statement
Exercise
Solution
The switch statement
Switch versus if
Exercise
Solution
Summary
4. Looping
The while loop
Infinite loops
Exercises
Solutions
The do/while loop
The for loop
Exercises
Solutions
Looping with Unreal Engine
Summary
5. Functions and Macros
Functions
An example of a <cmath> library function – sqrt()
Writing our own functions
A sample program trace
Exercise
Solution
Functions with arguments
Functions that return values
Exercises
Solutions
Variables, revisited
Global variables
Local variables
The scope of a variable
Static local variables
Const variables
Function prototypes
.h and .cpp files
prototypes.h contains
funcs.cpp contains
main.cpp contains
Extern variables
Macros
Advice – try to use const variables where possible
Macros with arguments
Advice – use inline functions instead of macros with arguments
Summary
6. Objects, Classes, and Inheritance
struct objects
Member functions
The this keyword
Strings are objects?
Invoking a member function
Exercises
Solutions
Privates and encapsulation
Some people like it public
class versus struct
Getters and setters
Getters
Setters
But what's the point of get/set operations?
Constructors and destructors
Class inheritance
Derived classes
Syntax of inheritance
What does inheritance do?
is-a relationship
protected variables
Virtual functions
Purely virtual functions (and abstract classes)
Multiple inheritance
private inheritance
Putting your classes into headers
.h and .cpp
Exercise
Summary
7. Dynamic Memory Allocation
Dynamic memory allocation
The delete keyword
Memory leaks
Regular arrays
The array syntax
Exercise
Solutions
C++ style dynamic size arrays (new[] and delete[])
Dynamic C-style arrays
Summary
8. Actors and Pawns
Actors versus pawns
Creating a world to put your actors in
The UE4 editor
Editor controls
Play mode controls
Adding objects to the scene
Starting from scratch
Adding light sources
Collision volumes
Adding collision detection for the objects editor
Adding an actor to the scene
Creating a player entity
Inheriting from UE4 GameFramework classes
Associating a model with the Avatar class
Downloading free models
Loading the mesh
Creating a blueprint from our C++ class
Writing C++ code that controls the game's character
Making the player an instance of the Avatar class
Setting up controller inputs
Exercise
Solution
Yaw and pitch
Creating non-player character entities
Displaying a quote from each NPC dialog box
Displaying messages on the HUD
Using TArray<Message>
Exercise
Solution
Triggering an event when it is near an NPC
Make the NPC display something to the HUD when something is nearby
Exercises
Solutions
Summary
9. Templates and Commonly Used Containers
Debugging the output in UE4
UE4's TArray<T>
An example that uses TArray<T>
Iterating a TArray
...

Table of contents