万本电子书0元读

万本电子书0元读

顶部广告

Procedural Content Generation for C++ Game Development电子书

售       价:¥

3人正在读 | 0人评论 9.8

作       者:Dale Green

出  版  社:Packt Publishing

出版时间:2016-01-30

字       数:185.9万

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

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

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Get to know techniques and approaches to procedurally generate game content in C++ using Simple and Fast Multimedia LibraryAbout This BookThis book contains a bespoke Simple and Fast Multimedia Library (SFML) game engine with complete online documentationThrough this book, you’ll create games that are non-predictable and dynamic and have a high replayability factorGet a breakdown of the key techniques and approaches applied to a real game.Who This Book Is ForIf you are a game developer who is familiar with C++ and is looking to create bigger and more dynamic games, then this book is for you. The book assumes some prior experience with C++, but any intermediate concepts are clarified in detail. No prior experience with SFML is required.What You Will LearnDiscover the systems and ideology that lie at the heart of procedural systemsUse Random number generation (RNG) with C++ data types to create random but controlled resultsBuild levels procedurally with randomly located items and eventsCreate dynamic game objects at runtimeConstruct games using a component-based approachAssemble non-predictable game events and scenariosOperate procedural generation to create dynamic content fast and easilyGenerate game environments for endless replayabilityIn DetailProcedural generation is a growing trend in game development. It allows developers to create games that are bigger and more dynamic, giving the games a higher level of replayability. Procedural generation isn’t just one technique, it’s a collection of techniques and approaches that are used together to create dynamic systems and objects. C++ is the industry-standard programming language to write computer games. It’s at the heart of most engines, and is incredibly powerful. SFML is an easy-to-use, cross-platform, and open-source multimedia library. Access to computer hardware is broken into succinct modules, making it a great choice if you want to develop cross-platform games with ease.Using C++ and SFML technologies, this book will guide you through the techniques and approaches used to generate content procedurally within game development.Throughout the course of this book, we’ll look at examples of these technologies, starting with setting up a roguelike project using the C++ template. We’ll then move on to using RNG with C++ data types and randomly scattering objects within a game map. We will create simple console examples to implement in a real game by creating unique and randomised game items, dynamic sprites, and effects, and procedurally generating game events. Then we will walk you through generating random game maps. At the end, we will have a retrospective look at the project.By the end of the book, not only will you have a solid understanding of procedural generation, but you’ll also have a working roguelike game that you will have extended using the examples provided.Style and approachThis is an easy-to-follow guide where each topic is explained clearly and thoroughly through the use of a bespoke example, then implemented in a real game project.
目录展开

Procedural Content Generation for C++ Game Development

Table of Contents

Procedural Content Generation for C++ Game Development

Credits

About the Author

Acknowledgment

About the Reviewer

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Extra Exercises

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

1. An Introduction to Procedural Generation

Procedural generation versus random generation

Procedural generation

Random generation

Introducing randomness

Pseudorandom number generation

Why computers can't generate truly random numbers

Generating random numbers in C++

Generating random numbers within a range

Seeds

Defining seeds

Using seeds

Generating random seeds during the runtime

Controlled randomness is the key to generating random numbers

The use of procedural generation in games

Saving space

Map generation

Texture creation

Animation

Sound

Benefits of procedural generation

Larger games can be created

Procedural generation can be used to lower budgets

An increase in gameplay variety

An increase in replayability

The drawbacks of procedural generation

More taxing on the hardware

Worlds can feel repetitive

You sacrifice quality control

You may generate an unplayable world

It is hard to script set game events

A brief history of rogue-like games

How we'll implement procedural generation

Populating environments

Creating unique game objects

Creating unique art

Audio manipulation

Behavior and mechanics

Dungeon generation

Component-based design

The complete game

Exercises

Summary

2. Project Setup and Breakdown

Choosing an IDE

Microsoft Visual Studio

Code::Blocks

Other IDEs

Build systems

Breaking down the game template

Download templates

The class diagram

The object hierarchy

Level data

Collision

Input

Simple and Fast Multimedia Library (SFML)

Defining SFML

Why we'll be using SFML

Learning SFML

Alternatives

Polymorphism

Inheritance

Virtual functions

Pure virtual functions

Pointers and object slicing

The roguelike template setup

Downloading SFML

Linking SFML

Running the project

Adding an item

Updating and drawing

Exercises

Summary

3. Using RNG with C++ Data Types

Setting the game seed

Setting Boolean values randomly

Generating a number between 0 and 1

Choosing if an item spawns

Random number distribution

Giving the player random stats

Accessing random elements of a collection

Spawning a random item

Generating random characters

Repeating loops

Spawning a random number of items

Exercises

Summary

4. Procedurally Populating Game Environments

Potential obstacles

Keeping within the bounds of a level

Avoiding overlapping objects

Creating meaningful levels

Level tiles

Defining the spawn area

Calculating the level bounds

Checking the underlying game grid

Selecting a suitable game tile

Randomly selecting a tile

Checking whether a tile is suitable

Converting to absolute position

Spawning items at a random location

Expanding the spawning system

Using enumerators to denote an object type

Optional parameters

The complete spawn functions

Updating the spawn code

Randomly spawning enemies

Spawning random tiles

Adding a new game tile

Choosing a random tile

Implementing the SpawnRandomTiles function

Exercises

Summary

5. Creating Unique and Randomized Game Objects

Creating a random player character

Choosing a player class

An overview of sprites and textures

Setting an appropriate sprite

Buffing the player stats

Random character traits

Returning the player traits array

Setting trait sprites

Procedurally generating an enemy class

Procedural items

Random Gem and Heart classes

Random gold class

The random potion class

Creating a random potion

Determining potion pickups

Exercises

Summary

6. Procedurally Generating Art

How procedural generation is used with art

Using sprite effects and modifiers

Combining multiple textures

Creating textures from scratch

Creating complex animations

The benefits of procedurally generated art

Versatility

Cheap to produce

It requires little storage

The drawbacks of procedurally generated art

Lack of control

Repeatability

Performance heavy

Using SFML sprite modifiers

How colors work in SFML

Creating sprites of a random color

Selecting a preset color at random

Generating a color at random

Creating sprites of a random size

Saving modified sprites

Passing a texture into an image

Drawing to a RenderTexture class

Saving an image to a file

Creating enemy sprites procedurally

Breaking sprites into components

The draw setup

Randomly selecting sprite components

Loading the default armor textures

Choosing the armor tier

Rendering the armor textures

Rendering the final textures

Overriding the default draw behavior

Debugging and testing

Editing the game tiles

Exercises

Summary

7. Procedurally Modifying Audio

An introduction to SFML audio

sf::Sound versus sf::Music

sf::SoundBuffer

Selecting a random main track

Adding sound effects

Editing sound effects

Playing a sound function

The audio listener

Creating a fluctuation in a pitch

3D sound – spatialization

The audio listener

The minimum distance

Attenuation

The position of the sound

Fixed positions

Moving positions

Exercises

Summary

8. Procedural Behavior and Mechanics

An introduction to pathfinding

What is a pathfinding algorithm?

Dijkstra's algorithm

The A* algorithm

A breakdown of A*

Representing a level as nodes

The open and closed list

The H, G, and F costs

The H value

The G value

The F value

The Manhattan distance

Parenting nodes

The pseudo-algorithm

Coding the A* pathfinding algorithm

The Tile datatype

Creating supporting functions

The Level class

The Enemy class

Variable declarations

Precalculating the H values

Defining the main loop

Finding the adjacent nodes

Calculating the G and F costs

Calculating the G and F cost

Checking for superior paths

Creating the final path

Implementing A* in the game

Enabling the enemy to follow a path

Calling the pathfinding behavior

Viewing our path

Procedurally generated level goals

The variable and function declarations

Generating a random goal

Checking whether a goal is complete

Drawing the goal on the screen

Exercises

Summary

9. Procedural Dungeon Generation

The benefits of procedural level design

Replayability

A reduction in development time

Larger game worlds

Considerations

A lack of control

Required computing power

Suitability

An overview of dungeon generation overview

Generating rooms

Generating a maze

Connecting rooms and mazes

The recursive backtracker

Procedurally generating a dungeon

Changing how we view the maze

Updating the Game and Level classes

Generating a maze

Preparing before the generation of a maze

Carving passages

Adding rooms

Choosing the tile textures

The if/else approach

Bitwise tile maps

Calculating the tile values

Mapping the tile value to textures

Calculating tile textures

Creating unique floor themes

Adding entry and exit points

Setting a player's spawn location

Undoing the debug changes

Exercises

Summary

10. Component-Based Architecture

Understanding component-based architecture

Problems with a traditional inheritance-based approach

Convoluted inheritance structures

Circular dependencies

Benefits of component-based architecture

Avoiding complex inheritance structures

Code is broken into highly reusable chunks

Highly maintainable and scalable

The disadvantages of component-based architecture

Code can become too fragmented

Unnecessary overhead

Complex to use

An overview

Designing the component system

C++ templates

Using templates

Template declarations

Using templates

Template specialization

Function overloading

Creating a base component

Component functions

Attaching a component

Retuning a component

Creating a transform component

Encapsulating transform behavior

Adding a transform component to the player

Using the transform component

Updating the game code

Creating a SpriteComponent

Encapsulating sprite behavior

Adding a sprite component to the player class

The updated drawing pipeline

Updating the game code

Creating an audio component

Defining the behavior of an audio component

Adding an audio component to the player class

Using the audio component

Exercises

Summary

11. Epilogue

Project breakdown

Procedurally populating environments

Creating unique and random game objects

Procedurally generating art

Procedurally modifying audio

Procedural behavior and mechanics

Procedural dungeon generation

Component-based architecture

The pros and cons of procedural generation

Pros

Cons

Summary

Index

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部