Beginning C++ Game Programming
eBook - ePub

Beginning C++ Game Programming

John Horton

Share book
  1. 520 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Beginning C++ Game Programming

John Horton

Book details
Book preview
Table of contents
Citations

About This Book

Learn C++ from scratch and get started building your very own games

About This Book

  • This book offers a fun way to learn modern C++ programming while building exciting 2D games
  • This beginner-friendly guide offers a fast-paced but engaging approach to game development
  • Dive headfirst into building a wide variety of desktop games that gradually increase in complexity
  • It is packed with many suggestions to expand your finished games that will make you think critically, technically, and creatively

Who This Book Is For

This book is perfect for you if any of the following describes you: You have no C++ programming knowledge whatsoever or need a beginner level refresher course, if you want to learn to build games or just use games as an engaging way to learn C++, if you have aspirations to publish a game one day, perhaps on Steam, or if you just want to have loads of fun and impress friends with your creations.

What You Will Learn

  • Get to know C++ from scratch while simultaneously learning game building
  • Learn the basics of C++, such as variables, loops, and functions to animate game objects, respond to collisions, keep score, play sound effects, and build your first playable game.
  • Use more advanced C++ topics such as classes, inheritance, and references to spawn and control thousands of enemies, shoot with a rapid fire machine gun, and realize random scrolling game-worlds
  • Stretch your C++ knowledge beyond the beginner level and use concepts such as pointers, references, and the Standard Template Library to add features like split-screen coop, immersive directional sound, and custom levels loaded from level-design files
  • Get ready to go and build your own unique games!

In Detail

This book is all about offering you a fun introduction to the world of game programming, C++, and the OpenGL-powered SFML using three fun, fully-playable games. These games are an addictive frantic two-button tapper, a multi-level zombie survival shooter, and a split-screen multiplayer puzzle-platformer.

We will start with the very basics of programming, such as variables, loops, and conditions and you will become more skillful with each game as you move through the key C++ topics, such as OOP (Object-Orientated Programming), C++ pointers, and an introduction to the Standard Template Library. While building these games, you will also learn exciting game programming concepts like particle effects, directional sound (spatialization), OpenGL programmable Shaders, spawning thousands of objects, and more.

Style and approach

This book offers a fun, example-driven approach to learning game development and C++. In addition to explaining game development techniques in an engaging style, the games are built in a way that introduces the key C++ topics in a practical and not theory-based way, with multiple runnable/playable stages in each chapter.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Beginning C++ Game Programming an online PDF/ePUB?
Yes, you can access Beginning C++ Game Programming by John Horton in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Programación en C++. We have over one million books available in our catalogue for you to explore.

Information

Year
2016
ISBN
9781786466198

Beginning C++ Game Programming


Beginning C++ Game Programming

Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2016
Production reference: 3191016
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-619-8
www.packtpub.com

Credits

Author
John Horton
Copy Editor
Safis Editing
Reviewer
Glen De Cauwsemaecker
Project Coordinator
Ulhas Kambali
Commissioning Editor
Wilson D'souza
Proofreader
Safis Editing
Acquisition Editor
Tushar Gupta
Indexer
Tejal Daruwale Soni
Content Development Editor
Onkar Wani
Production Coordinator
Aparna Bhagat
Technical Editor
Rashil Shah
Cover Work
Aparna Bhagat

About the Author

John Horton is a coding and gaming enthusiast based in the UK.
He has a passion for writing apps, games, books, and blog articles about programming, especially for beginners. He is the founder of Game Code School, http://www.gamecodeschool.com, which is dedicated to helping complete beginners get started coding using the language and platform that is best for them.
John sincerely believes that anyone can learn to code and that everybody has a game or an app inside of them, and that they just need to do enough work to bring it out.
He has authored around a dozen technology books, most recently the following:
Beginning C++ Game Programming: https://www.packtpub.com/game-development/beginning-c-game-programming
Android Programming for Beginners: https://www.packtpub.com/application-development/android-programming-beginners
Android Game programming by Example: https://www.packtpub.com/game-development/android-game-programming-example
Learning Java Building Android Games: https://www.packtpub.com/game-development/learning-java-building-android-games

About the Reviewer

Glen De Cauwsemaecker, commonly known as glendc, is an open source hacker from Belgium. Currently, he lives a nomadic life in South America, while working freelance for the UK games industry. Glen is passionate about open source technology, as much as exploring new cultures and countries. This is why he became in 2015 a digital nomad, after living and working in the UK for 2 years.
I would like to thank my girlfriend, Elizabeth Gonzales Belsuzarri, for her support and love. I would also like to thank Exient Ltd., my employer for the last 3 years, for providing me with the chance to work remotely, while living nomadically.

www.PacktPub.com

eBooks, discount offers, and more

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
eBooks, discount offers, and more
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

  • Fully searchable across every book published by Packt
  • Copy and paste, print, and bookmark content
  • On demand and accessible via a web browser

Dedication

Dedicated to everyone who has no place to stay or insufficient strength to live. Especially to those who used up all their strength serving someone else.

Preface

This book is about learning C++ programming the fun way. Starting from zero experience, you will learn the basics of C++, such as variables and loops, through to advanced topics, such as inheritance and polymorphism. Everything you learn will be put into practice building three fully-playable games.
These are our three projects for the book.

Timber!!!

The first game is an addictive, fast-paced clone of the hugely successful Timberman, http://store.steampowered.com/app/398710/. Our game, Timber!!!, will allow us to be introduced to all the C++ basics at the same time as building a genuinely playable game.

Zombie Arena

Next we will build a frantic, zombie survival-shooter, not unlike the Steam hit, Over 9,000 Zombies, http://store.steampowered.com/app/273500/. The player will have a machine gun, and must fight off ever growing waves of zombies. All this will take place in a randomly generated, scrolling world. To achieve this, we will learn about object-oriented programming and how it enables us to have a large code base (lots of code) that is easy to write and maintain. Expect exciting features such as hundreds of enemies, rapid-fire weaponry, pick-ups and a character that can be "leveled-up" after each wave.

Thomas was Late

The third game will be a stylish and challenging, single player and co-op puzzle platformer. It is based on the very popular game, Thomas was Alone, http://store.steampowered.com/app/220780/. Expect to learn cool topics such as particle effects, OpenGL Shaders, and split-screen cooperative multiplayer.

What this book covers

Chapter 1, C++, SFML, Visual Studio, and Starting the First Game, this is quite a hefty first chapter, but we will learn absolutely everything we need in order to have the first part of our first game up and running. Here is what we will do:
  • Find out more about the games we will build
  • Learn a bit about C++
  • Explore SFML and its relationship with C++
  • Look at the software, Visual Studio, that we will use throughout the book
  • Set up a game development environment
  • Create a reusable project template, which will save a lot of time
  • Plan and prepare for the first game project, Timber!!!
  • Write the first C++ code of the book and make a runnable game that draws a background
Chapter 2, Variables, Operators, and Decisions – Animating Sprites, in this chapter, we will do quite a bit more drawing on the screen, and to achieve this we will need to learn some of the basics of C++. Here is what is in store:
  • Learn all about C++ variables
  • See how to manipulate the values stored in variables
  • Add a static tree, ready for the player to chop
  • Draw and animate a bee and three clouds
Chapter 3, C++ Strings, SFML Time – Player Input, and HUD, in this chapter, we will spend around half the time learning how to manipulate text and display it on the screen, and the other half looking at timing and how a visual tim...

Table of contents