If you want to learn to program the first-class games, you need to learn language C ++. This book will help you to master development of games from the elements irrespective of whether you have an experience of programming. It is much more interesting to study when training turns into game. Each chapter of the book describes the independent game project. In the final chapter you should write difficult game which integrates all acceptances of programming considered in the previous heads. The book will be ideally suited for the beginning programmer who is going not only to master properly difficult language C ++, but also to practice in programming of games. The purpose of this book — to acquaint you with language C ++ in the context of programming of games. Though it is impossible to imagine such book which would make you the master in two so volume subjects as programming of games and language C ++, this edition is useful to you as an introduction course.
For whom this book
This book for all who wish to learn programming of games. It is expected beginners, reading requires no experience of programming. If you well are able to use own computer, can begin an Odyssey to the world of programming of games right now. But the fact that this book is expected beginners, does not mean yet what to master With ++ for programming of games will be as easy as shelling pears. It is necessary to read, work, experiment attentively. Having read up this book, you will acquire solid basic knowledge on the major language for professional programming of games.
As the book is constructed
I begin the story about programming of games on C ++ from scratch, assuming that the reader has no experience neither in programming of games, nor in C ++. In each new chapter harder and harder subjects are considered, each subsequent head is based on material from previous.
In each chapter a certain subject or several interconnected subjects are considered. I pass from one concept to another, accompanying the text with the small game programs illustrating each idea. At the end of each chapter I integrate the most important of the concepts considered in it, bringing to your attention ready game. Final chapter comes to the end with the most nontrivial project where we involve all main phenomena studied in the book.
Having read up this book, you will not just master language C ++ and gain an impression about programming of games. You also learn to organize the work, to subdivide problems into small digestible subtasks, to perfect a code. On pages of the book you should face constantly tests, but any of them will not be insuperable. In general you are waited by amusing and interesting training. Therein you will write several cool computer games and will comprehend craft of game programming.
Chapter 1. Types, variables, standard input-output. Game "The Lost Treasure". Here you will get acquainted with bases of C ++ — the major programming language which is applied in the game industry. You learn to display an output in a console window, to execute arithmetic calculations, to work with variables and to receive the user input gathered on the keyboard.
Chapter 2. Truth, branching and game cycle. Game "Guess Number". Many interesting games are based on programs which execute, pass or repeatedly execute certain blocks of a code depending on these or those conditions. You learn to generate random numbers that will allow to add an unpredictability element to your games. Besides, you will get acquainted with the fundamental phenomenon called "a game cycle". This cycle allows to organize game and to build in it series of events.
Chapter 3. Cycles for, lines and arrays. Game of "Slovomesk". You learn about game sequences and learn to work with lines. The line is string, irreplaceable at game in words. Besides, you will get acquainted with software objects — the entities allowing to represent in your game beings or objects. Examples of entities — the alien spaceship, a pot with a medical potion or the character.
Chapter 4. Library of standard templates. Game "Gallows". Here you will get acquainted with powerful library — tools for developers of games (and not only games). This library allows to integrate elements in collections and to store them in such type, for example, as equipment in a backpack at the character. Besides, the acceptances allowing to create larger game programs will be considered here.
Chapter 5. Functions. Game "Mad Librarians". In this chapter you learn to break game programs into compact blocks with which it is convenient to work. For this purpose you will get acquainted with functions — the elementary logical units applied in programs.
Chapter 6. Links. Game "Tic-tac-toe". Here we will talk about how at the same time to use certain information in different parts of your program, and to do it accurately and effectively. Besides, here you will get acquainted with artificial intelligence and learn how to make the computer rival a little more inventively.
Chapter 7. Pointers. Game "Tic-tac-toe 2.0". In this chapter you will get acquainted with some most low-level and powerful opportunities of language C ++. In particular, we will talk about how to address directly computer memory and to manipulate it.
Chapter 8. Classes. Game "Tamagochi". Here you learn to create own objects and to describe how they have to interact with each other. The object-oriented programming paradigm is for this purpose applied. You will create own favourite-tamagochi for whom you will care.
Chapter 9. More difficult classes and work with a dynamic memory. Game lobby. In this chapter you learn to interact even more densely with the computer, in particular to occupy and release memory if it is demanded by game process. Also you learn about the reefs connected with such dynamic use of memory, and learn to bypass them.
Chapter 10. Inheritance and polymorphism. Game Blackjack. In this chapter we will talk about how to create objects by means of other objects. Then we will generalize all studied material in big final game. You will see how quite volume game is projected and implemented, namely the virtual simulator of classical hazardous gambling Blackjack (on a card-table somehow we will do without shabby cloth).
The source code to the book
All source code to examples from this book is available on the Internet to the address www.cengageptr.com/downloads
About the author
Michael Dawson is the author writing about computer games and also the teacher training students to art and science of creation of computer games. Michael developed and gave courses on programming of games at faculty of UCLA Extension at the Californian university of Los Angeles (students of this faculty get second higher education). Also Michael gave lectures in Academy of digital and media technologies (DMA) and at Cinema school of Los Angeles. Dawson's books are included into the obligatory program of many universities and colleges in the USA.
Michael began career in the game industry as the producer and the designer. In parallel with it he began to develop adventure game where the user manages the main character by the name of Mike Dawson. On a game plot the digital double of Dawson has to prevent invasion of aliens before at it from the head the implanted larva of newcomers hatches.
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 received degree of the bachelor of cybernetics at university of South California. In more detail it is possible to read about the author and his books on the personal website of the author, here you will find answers to many questions according to Michael's books.
It is possible to get acquainted with the book on website of publishing house in more detail
Table of contents
For Habrozhitely a discount of 25% according to the coupon — we Study C ++
This article is a translation of the original post at habrahabr.ru/post/270559/
If you have any questions regarding the material covered in the article above, please, contact the original author of the post.
If you have any complaints about this article or you want this article to be deleted, please, drop an email here: firstname.lastname@example.org.
We believe that the knowledge, which is available at the most popular Russian IT blog habrahabr.ru, should be accessed by everyone, even though it is poorly translated.
Shared knowledge makes the world better.