Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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

Arrow left icon
Profile Icon Dale Green
Arrow right icon
Free Trial
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7 (7 Ratings)
Paperback Jan 2016 304 pages 1st Edition
eBook
zł59.99 zł177.99
Paperback
zł221.99
Subscription
Free Trial
Arrow left icon
Profile Icon Dale Green
Arrow right icon
Free Trial
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.7 (7 Ratings)
Paperback Jan 2016 304 pages 1st Edition
eBook
zł59.99 zł177.99
Paperback
zł221.99
Subscription
Free Trial
eBook
zł59.99 zł177.99
Paperback
zł221.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781785886713
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jan 30, 2016
Length: 304 pages
Edition : 1st
Language : English
ISBN-13 : 9781785886713
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 zł20 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 zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 625.97
Procedural Content Generation for C++ Game Development
zł221.99
SFML Game Development By Example
zł221.99
C++ Game Development Cookbook
zł181.99
Total 625.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.