Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Procedural Content Generation for C++ Game Development
Procedural Content Generation for C++ Game Development

Procedural Content Generation for C++ Game Development: Get to know techniques and approaches to procedurally generate game content in C++ using Simple and Fast Multimedia Library

eBook
$38.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Procedural Content Generation for C++ Game Development

Chapter 2. Project Setup and Breakdown

Before we get into the implementation of procedural generation for ourselves, we're going to take a quick tour through the game template that has been provided with the book. Moving forward, the focus will be on the procedural systems that we create, not the underlying template and engine. Given that, it will be beneficial to familiarize ourselves with the templates and engine before we start.

We'll also take a look at Simple Fast Multimedia Library (SFML), the framework that we'll work with.

In this chapter, we'll cover the following topics:

  • Choosing an Integrated Development Environment (IDE)
  • A breakdown of the provided game template
  • An overview of SFML
  • Polymorphism
  • Project setup and first compile
  • Object pipeline

Choosing an IDE

Before we do anything, you're going to need a solid C++ IDE. You may already have one that you prefer to use. If you do have one, that's fine. But if you don't, here's a quick summary of two of my favorites.

Microsoft Visual Studio

Microsoft Visual Studio is an industry-standard IDE from Microsoft. It supports a wide range of languages, and provides a large variety of testing and compatibility tools. It's also tied in with a number of Microsoft services, making it the top choice for development on Windows PCs. The pros and cons to using Microsoft Visual Studio are as follows:

Pros:

  • It has a number of free versions available
  • A wide range of languages are supported by Microsoft Visual Studio
  • It is widely supported by Microsoft
  • It has a highly customizable environment with dockable windows
  • It has intelligent code completion features
  • It is integrated with a number of Microsoft features

Cons:

  • Its full version is very expensive
  • Its free version is limited
  • Works...

Breaking down the game template

The best way to learn is by practicing. Examples are great, but there's nothing like getting stuck in and working on a real game. The game template provided will allow us to implement the systems that we're going to learn about in a real game as opposed to them being a collection of isolated exercises.

Familiarizing yourself with this template will not only help make the code examples throughout the book clearer, but also make the exercises at the end of each chapter easier. It will also allow you to use what you're learning to implement your own systems in the project once we're done with it.

Download templates

Before you start, download the game template so that you have the source code available as you run through some of the key points. The template is available for download on the official Packt Publishing website at http://www.packtpub.com/support.

We'll set it up shortly, but for now, let's take a quick look at some of its...

Simple and Fast Multimedia Library (SFML)

Whilst you will have experience with C++, you may not have any prior experience with SFML. That's fine, the book doesn't assume any, so now let's take a brief tour through it

Defining SFML

SFML, short for Simple and Fast Multimedia Library, is a software development library that provides easy access to multiple system components. It's written in C++ and is split into the following succinct modules:

  • System
  • Windows
  • Graphics
  • Audio
  • Network

With this architecture you can easily pick and choose how you want to use SFML, ranging from a simple window manager to use OpenGL, to a complete multimedia library that is capable of making full video games and multimedia software.

Why we'll be using SFML

SFML is both free, open-source, and has a vibrant community. With active forums and a selection of great tutorials on the official site, there are plenty of resources available for those who wish to learn. Another compelling reason to use SFML is...

Polymorphism

Before we get started with the game template, we're going to take a look at polymorphism. It's an important feature of object-orientated programming that we will be taking advantage of in many of the procedural systems that we will create. Therefore, it's important that you have a solid understanding of not only what it is, but also the techniques that are used to achieve it and the potential pitfalls.

Tip

If you already have a strong understanding of polymorphism, feel free to skip this section or head to https://msdn.microsoft.com/en-us/library/z165t2xk(v=vs.90) for a more in-depth discussion of the topic.

Polymorphism is the ability to access different objects through an individually implemented common interface. That's a very formal definition. So, let's break that down into the individual techniques and features that are used to achieve it. It's worth noting that while polymorphism is the standard approach in the games industry, it's still...

The roguelike template setup

A template is provided with this book for a roguelike game that was created specifically for the book. It's been designed to receive the work that we'll cover, and at the end of the book, you'll have a fully functional roguelike game that implements everything that you will have learned. Now that we've brushed up on our understanding of polymorphism, let's get the template setup. The first step is to download and link SFML.

Tip

The project, as provided, is linked with SMFL 32-bit windows libraries. This should suit most systems. If this is compatible with your system, you can skip the following steps.

Downloading SFML

SFML is available in a number of different precompiled packages. For example, the latest release at the time of writing this book has 12 packages available for Windows alone, so it's important that you download the correct one for your system. The following steps will help you to download and setup SFML:

  1. Visit at http:...

Choosing an IDE


Before we do anything, you're going to need a solid C++ IDE. You may already have one that you prefer to use. If you do have one, that's fine. But if you don't, here's a quick summary of two of my favorites.

Microsoft Visual Studio

Microsoft Visual Studio is an industry-standard IDE from Microsoft. It supports a wide range of languages, and provides a large variety of testing and compatibility tools. It's also tied in with a number of Microsoft services, making it the top choice for development on Windows PCs. The pros and cons to using Microsoft Visual Studio are as follows:

Pros:

  • It has a number of free versions available

  • A wide range of languages are supported by Microsoft Visual Studio

  • It is widely supported by Microsoft

  • It has a highly customizable environment with dockable windows

  • It has intelligent code completion features

  • It is integrated with a number of Microsoft features

Cons:

  • Its full version is very expensive

  • Its free version is limited

  • Works only on Windows PC

Tip

Microsoft...

Breaking down the game template


The best way to learn is by practicing. Examples are great, but there's nothing like getting stuck in and working on a real game. The game template provided will allow us to implement the systems that we're going to learn about in a real game as opposed to them being a collection of isolated exercises.

Familiarizing yourself with this template will not only help make the code examples throughout the book clearer, but also make the exercises at the end of each chapter easier. It will also allow you to use what you're learning to implement your own systems in the project once we're done with it.

Download templates

Before you start, download the game template so that you have the source code available as you run through some of the key points. The template is available for download on the official Packt Publishing website at http://www.packtpub.com/support.

We'll set it up shortly, but for now, let's take a quick look at some of its key features.

The class diagram...

Left arrow icon Right arrow icon

Key benefits

  • *This book contains a bespoke Simple and Fast Multimedia Library (SFML) game engine with complete online documentation
  • *Through this book, you’ll create games that are non-predictable and dynamic and have a high replayability factor
  • *Get a breakdown of the key techniques and approaches applied to a real game.

Description

Procedural 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.

Who is this book for?

If 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 learn

  • *Discover the systems and ideology that lie at the heart of procedural systems
  • *Use Random number generation (RNG) with C++ data types to create random but controlled results
  • *Build levels procedurally with randomly located items and events
  • *Create dynamic game objects at runtime
  • *Construct games using a component-based approach
  • *Assemble non-predictable game events and scenarios
  • *Operate procedural generation to create dynamic content fast and easily
  • *Generate game environments for endless replayability

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 30, 2016
Length: 304 pages
Edition : 1st
Language : English
ISBN-13 : 9781785886355
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jan 30, 2016
Length: 304 pages
Edition : 1st
Language : English
ISBN-13 : 9781785886355
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 154.97
Procedural Content Generation for C++ Game Development
$54.99
SFML Game Development By Example
$54.99
C++ Game Development Cookbook
$44.99
Total $ 154.97 Stars icon

Table of Contents

12 Chapters
1. An Introduction to Procedural Generation Chevron down icon Chevron up icon
2. Project Setup and Breakdown Chevron down icon Chevron up icon
3. Using RNG with C++ Data Types Chevron down icon Chevron up icon
4. Procedurally Populating Game Environments Chevron down icon Chevron up icon
5. Creating Unique and Randomized Game Objects Chevron down icon Chevron up icon
6. Procedurally Generating Art Chevron down icon Chevron up icon
7. Procedurally Modifying Audio Chevron down icon Chevron up icon
8. Procedural Behavior and Mechanics Chevron down icon Chevron up icon
9. Procedural Dungeon Generation Chevron down icon Chevron up icon
10. Component-Based Architecture Chevron down icon Chevron up icon
11. Epilogue Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7
(7 Ratings)
5 star 28.6%
4 star 14.3%
3 star 0%
2 star 14.3%
1 star 42.9%
Filter icon Filter
Top Reviews

Filter reviews by




S. Morris Sep 11, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I thought the book and the included code were a riot. The book opens with a working rpg game shell and you can follow the book and learn how to modify the game as you go along. How to add random foes and treasure and even create random stuff on the fly (procedural) It was a different concept for a book - great SFML learning tool to tear into the existing code to see how it works. Not a SFML starter book but if you have done one of the other packt books on SFML, or in my case two, you should have no problems picking this up. I think that the author (or publisher) missed an opportunity to add 100 pages and talk about the game shell programming first which would have made it ideal and better for the novice game programmer.
Amazon Verified review Amazon
William Oct 10, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
One of the best books I've read on game programming, and programming in general. For real!The author does a great job at explaining things, from simple to complex subjects, and provide all the assets you need to have a fully working game in the end. I'm new to game programming, and yet I'm able to follow along with this book just fine. Just beware that you should know some C++ before going into this adventure.Definitely worth the money. We need more content like this.
Amazon Verified review Amazon
Amazon Customer May 13, 2017
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good clear book with a complete working game in c++.Easy to continue with more advanced sfml books.
Amazon Verified review Amazon
Zoe Oct 19, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
In short: The goal of this book is to give only an introduction to proceduralcontent generation and is more for a beginner in C++ than for advanced coders.It comes with some errors and lacks for me some topics while could get rid ofothers.Pro:* showing how to randomize with rand and srand (because on iOS and Android it might crash with the C++11 generators)* explanation of pseudorandom number generators and simple vs. those used for crypto was ok* putting COUNT as last element of enum classes* creating a maze with codeCons:* a lot beginner level information ** setup (Visual Studio and Code::Blocks) ** OOP (polymorphism, inheritance, virtual functions) ** templates ** function overloading ** optional parameters ** modulo operator ** casting ** tips like "organize your code in a folder structure"* "out of scope topics" (topics which were said didn't fit into the book) ** procedural image creation such as with Perlin noise ** 3D terrain generation ** texture generation* not talking about C++11 random generators at all* sometimes using smart pointers, sometimes not (should be at least stick to one way)* showed only very simple pseudorandom number generation (also it might often be enough for the use-cases in the book)* when talking about storage concerns not talking about mobile clients (there the download size still matters...)* class diagram could have been printed in the book instead of being only available in the download* no CD - only download (Internet may change, so the contents might become unavailable)* repeated what the code does like "loop forever" in front of a while-true scenario multiple times in the comments* code errors and line-breaks even in the middle of variable names - once there is even a comment with a line break and the code afterwards sadly then looks like being part of the comment* use of C-array instead of vector - resulting in a section about how to return the C-array from a function - why not simply use a vector? (p. 97-98)* gray-scale screenshots in the printed book make it often difficult to see the differences, especially because the author often refers to that red or blue dot while both are just gray. Would have preferred to pay more for the book with colored images.* coding style differs in the examples* it's nice to have 3D-sound in, but I wouldn't call it a procedural generated content topic* I'm actually missing a block-based generated level like needed for Sokoban or side-scrollers, but because this book is only about one game, we only create a maze* p. 176 why is it not using the erase-remove idiom here?* sometimes "using namespace std;", sometimes not* component based architecture is not that great implemented. There are really better ways. Maybe a beginner would wirte it like that.* A* pathfinding was explained well, but for me that would fit more into an AI book - I mean it could be used to check the maze for being solvable, but that isn't even mentioned at that pointSo well - yes, it meets its goal, but I am somehow disappointed about the quality and contents. If the author would have let out all that noob-C++-coder stuff and the off-topic contents, he could have shown another way of generating levels (for example with blocks for a small Sokoban or side-scroller or whatever).
Amazon Verified review Amazon
Grzegorz Dalek Jun 20, 2017
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
I'm very disappointed by this book. It's lazy in terms of writing and presentation. Seems like a demo version or first draft rather than complete book. It clearly shows lack of experience of the author in the subject of procedural generation.There is no take on different approaches / algorithms. 80 % of the book is generating random number and hard-coding what it's supposed to do. Create classes for 5 different potions, and if you roll 1 then you spawn potion number 1. Here is the book. I don't think anybody who is proficient enough in C++ to understand the book needs tutorial on that.Parts of the book are repeated few times such as pros and cons of procedural generation. It's explained there 3 times each time taking few pages repeating the same stuff. Come on.The code is messy, chaotically explained. I was impressed by how complex explanation of the simple ideas was at times. There are parts of the book not even related to the subject - or hardly related such as how awesome component based architecture is in Unity or Pathfinding section with most basic implementation of A* explained.All illustrations in the book are black and white - and author uses color to illustrate the changes. As a result you end up staring at two or three identical images like a moron.If you're interested in procedural generation just look at the internet and you'll find way more comprehensive resources on the subject, for free.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.