The book "Learning C ++ through game programming"
If you want to learn how to program first-class games, you just need to learn the C ++ language. This book will help you master the development of games from the very basics, regardless of whether you have programming experience. Learning is much more interesting when learning turns into a game. Each chapter of the book describes an independent game project. In the final chapter, you will write a complex game that combines all the programming techniques discussed in previous chapters. The book is ideal for a novice programmer who plans not only to properly learn the difficult C ++ language, but also to practice programming games. The purpose of this book is to introduce you to the C ++ language in the context of game programming. Although it’s impossible to imagine a book that would make you a master in two such voluminous topics,
Who is this book for?
This book is for anyone who wants to learn how to program games. It is designed for beginners, it does not require any programming experience to read. If you know how to use your own computer, you can start an odyssey in the world of programming games right now. But the fact that this book is intended for beginners does not mean that mastering C ++ for programming games will be as easy as shelling pears. Have to carefully read, work, experiment. After reading this book, you will gain solid basic knowledge of the most important language for professional game programming.
How the book is built
I begin the story about programming games in C ++ with the basics, assuming that the reader has no experience in programming games, nor in C ++. Each new chapter discusses increasingly complex topics, each subsequent chapter is based on material from the previous ones.
Each chapter addresses a specific topic or several related topics. I move from one concept to another, accompanying the text with small game programs illustrating each idea. At the end of each chapter I combine the most important of the concepts discussed in it, offering you a ready-made game. The final chapter concludes with the most non-trivial project, where we use all the basic phenomena studied in the book.
After reading this book, you will not just learn the C ++ language and get an idea of game programming. You will also learn how to organize your work, subdivide problems into small digestible subtasks, and hone the code. On the pages of the book you will have to constantly face trials, but not one of them will be insurmountable. In general, you will find fun and interesting training. Along the way, you will write some cool computer games and learn the craft of gaming programming.
Chapter 1. Types, variables, standard input-output. The game "Lost Treasure". Here you will learn the basics of C ++ - the most important programming language that is used in the gaming industry. You will learn how to display output in the console window, perform arithmetic calculations, work with variables and receive user input typed on the keyboard.
Chapter 2. Truth, branching, and the game loop. Guess the number game. Many interesting games are based on programs that execute, skip, or re-execute certain blocks of code depending on certain conditions. You will learn how to generate random numbers, which will add an element of unpredictability to your games. In addition, you will get acquainted with the fundamental phenomenon called the “game cycle”. It is this cycle that allows you to organize the game and build a series of events in it.
Chapter 3. For loops, strings, and arrays. The game "Slovomesk". You will learn about game sequences and learn how to work with strings. A string is a sequence of characters that is indispensable when playing a word game. In addition, you will get acquainted with software objects - entities that allow you to represent creatures or objects in your game. Examples of entities are an alien spaceship, a potion with healing potion, or the character himself.
Chapter 4. Library of standard templates. The game "Hangman." Here you will get acquainted with a powerful library - a toolkit for game developers (and not only games). This library allows you to combine elements in collections and store them in such a way, for example, as equipment in a character’s backpack. In addition, here we will consider techniques that allow you to create larger game programs.
Chapter 5. Functions. The game "Mad Librarians." In this chapter, you will learn how to break game programs into compact blocks that are convenient to work with. To do this, you will get acquainted with functions - elementary logical units used in programs.
Chapter 6. References. The game "Tic Tac Toe." Here we will talk about how to simultaneously use certain information in different parts of your program, and to do it clearly and efficiently. In addition, here you will get acquainted with artificial intelligence and learn how to make a computer opponent a little more inventive.
Chapter 7. Pointers. The game "Tic Tac Toe 2.0". In this chapter, you will learn about some of the most low-level and powerful features of the C ++ language. In particular, we will talk about how to directly access and manipulate computer memory.
Chapter 8. Classes. The game "Tamagotchi". Here you will learn how to create your own objects and describe how they should interact with each other. For this, the paradigm of object-oriented programming is used. You will create your own Tamagotchi pet to take care of.
Chapter 9. More complex classes and work with dynamic memory. Gaming lobby. In this chapter, you will learn how to interact even more closely with a computer, in particular, occupy and free up memory if the game requires this. You will also learn about the pitfalls associated with such dynamic memory usage, and learn how to get around them.
Chapter 10. Inheritance and polymorphism. Blackjack game. In this chapter, we will talk about how to create objects using other objects. Then we summarize all the material studied in the big final game. You will see how a rather voluminous game is designed and implemented, namely a virtual simulator of the classic Blackjack gambling card game (we’ll somehow manage without shabby cloth on the ombre table).
Source code for the book
All source code for examples from this book is available online at www.cengageptr.com/downloads
about the author
Michael Dawson is an author who writes about computer games, as well as a teacher who teaches students the art and science of creating computer games. Michael developed and taught games programming courses at the UCLA Extension faculty at the University of California, Los Angeles (students of this faculty receive a second higher education). Michael also lectured at the Academy of Digital and Media Technology (DMA) and at the Los Angeles Film School. Dawson's books are part of the compulsory program of many universities and colleges in the USA.
Michael began his career in the gaming industry as a producer and designer. In parallel, he began to develop an adventure game where the user controls a main character named Mike Dawson. According to the plot of the game, Dawson's digital double should prevent the invasion of aliens before an implanted alien larva hatches from his head.
In reality, Michael is known as the author of several books: Beginning C ++ Through Game Programming, Python Programming for the Absolute Beginner, C ++ Projects: Programming with Text-Based Games and Guide to Programming with Python. Dawson holds a BS in cybernetics from the University of Southern California. You can read more about the author and his books on the author’s personal website , here you will find answers to many questions about Michael’s books.
You can familiarize yourself with the book in more detail on the publisher's website.
For Habrozhitelami 25% discount on the coupon - Learn C