万本电子书0元读

万本电子书0元读

顶部广告

Learning C++ by Creating Games with UE4电子书

售       价:¥

132人正在读 | 0人评论 6.2

作       者:William Sherif

出  版  社:Packt Publishing

出版时间:2015-02-24

字       数:251.7万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
If you are really passionate about games and have always wanted to write your own, this book is perfect for you. It will help you get started with programming in C++ and explore the immense functionalities of UE4.
目录展开

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

The vanilla for loop and square brackets notation

Iterators

Finding whether an element is in the TArray

TSet<T>

Iterating a TSet

Intersecting TSet

Unioning TSet

Finding TSet

TMap<T, S>

A list of items for the player's inventory

Iterating a TMap

C++ STL versions of commonly used containers

C++ STL set

Finding an element in a <set>

Exercise

Solution

C++ STL map

Finding an element in a <map>

Exercise

Solution

Summary

10. Inventory System and Pickup Items

Declaring the backpack

Forward declaration

Importing assets

Attaching an action mapping to a key

Base class PickupItem

The root component

Getting the avatar

Getting the player controller

Getting the HUD

Drawing the player inventory

Using HUD::DrawTexture()

Exercise

Detecting inventory item clicks

Dragging elements

Exercises

Summary

11. Monsters

Landscape

Sculpting the landscape

Monsters

Basic monster intelligence

Moving the monster – steering behavior

The discrete nature of monster motion

Monster SightSphere

Monster attacks on the player

Melee attacks

Defining a melee weapon

Coding for a melee weapon in C++

Downloading a sword

Creating a blueprint for your melee weapon

Sockets

Creating a skeletal mesh socket in the monster's hand

Attaching the sword to the model

Code to equip the player with a sword

Triggering the attack animation

Blueprint basics

Modifying the animation blueprint for Mixamo Adam

Code to swing the sword

Projectile or ranged attacks

Bullet physics

Adding bullets to the monster class

Player knockback

Summary

12. Spell Book

The particle systems

Changing particle properties

Settings for the blizzard spell

Spell class actor

Blueprinting our spells

Picking up spells

Creating blueprints for PickupItems that cast spells

Attaching right mouse click to cast spell

Writing the avatar's CastSpell function

Instantiating the spell – GetWorld()->SpawnActor()

if(spell)

spell->SetCaster(this)

Writing AMyHUD::MouseRightClicked()

Activating right mouse button clicks

Creating other spells

The fire spell

Exercises

Summary

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部