Procedural Content Generation for C++ Game Development

 
 
Packt Publishing Limited
  • 1. Auflage
  • |
  • erschienen am 30. Januar 2016
  • |
  • 304 Seiten
 
E-Book | ePUB mit Adobe DRM | Systemvoraussetzungen
978-1-78588-635-5 (ISBN)
 
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.
  • Englisch
  • Birmingham
  • |
  • Großbritannien
978-1-78588-635-5 (9781785886355)
1785886355 (1785886355)
weitere Ausgaben werden ermittelt
Dale Green is a young software developer who started his professional programming career in VB.NET, writing bespoke solutions to automate business tasks. This included the writing and maintenance of an e-commerce site that sold products on big online marketplaces such as Amazon and Rakuten.
Prior to this, he's been creating computer games since his early high school days. Through self-teaching, Dale has worked with a number of game development tools such as GameMaker, Unity, and Unreal before finding home in C++/DirectX/OpenGL after undertaking a degree in the subject.
Currently studying computer games programming BSc (Hons) at the University of Huddersfield, he is on track to graduate with a first-class degree. Alongside his studies, he is a teaching assistant who helps deliver course content to fellow undergraduates. He undertook a year of self-employment to publish his first commercial title on Steam, Samphi, through his indie studio, Greeny Games Studio.
As a hobby, Dale also operates the indie game news website named Indie Gamers UK and enjoys playing with new technologies and languages.
  • Cover
  • Copyright
  • Credits
  • About the Author
  • Acknowledgment
  • About the Reviewer
  • www.PacktPub.com
  • Table of Contents
  • Preface
  • Chapter 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
  • Chapter 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
  • Chapter 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
  • Chapter 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
  • Chapter 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
  • Chapter 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
  • Chapter 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
  • Chapter 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
  • Chapter 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
  • Chapter 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 behaviour
  • 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
  • Chapter 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

Dateiformat: EPUB
Kopierschutz: Adobe-DRM (Digital Rights Management)

Systemvoraussetzungen:

Computer (Windows; MacOS X; Linux): Installieren Sie bereits vor dem Download die kostenlose Software Adobe Digital Editions (siehe E-Book Hilfe).

Tablet/Smartphone (Android; iOS): Installieren Sie bereits vor dem Download die kostenlose App Adobe Digital Editions (siehe E-Book Hilfe).

E-Book-Reader: Bookeen, Kobo, Pocketbook, Sony, Tolino u.v.a.m. (nicht Kindle)

Das Dateiformat EPUB ist sehr gut für Romane und Sachbücher geeignet - also für "fließenden" Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein "harter" Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.

Weitere Informationen finden Sie in unserer E-Book Hilfe.


Download (sofort verfügbar)

40,53 €
inkl. 19% MwSt.
Download / Einzel-Lizenz
ePUB mit Adobe DRM
siehe Systemvoraussetzungen
E-Book bestellen

Unsere Web-Seiten verwenden Cookies. Mit der Nutzung dieser Web-Seiten erklären Sie sich damit einverstanden. Mehr Informationen finden Sie in unserem Datenschutzhinweis. Ok