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:
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:
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 time-bar can inform the player and create a sense of urgency in the game. We will cover:
Chapter 4, Loops, Arrays, Switch, Enumerations, and Functions – Implementing Game Mechanics, this chapter probably has more C++ information than any other chapter in the book. It is packed with fundamental concepts that will move our understanding on enormously. It will also begin to shed light on some of the murky areas we have been skipping over a little bit like functions and the game loop. Once we have explored a whole list of C++ language necessities, we will then use everything we know to make the main game mechanic, the tree branches, move. By the end of this chapter, we will be ready for the final phase and the completion of Timber!!!. Get ready for the following topics:
Chapter 5, Collisions, Sound, and End Conditions – Making the Game Playable, this is the final phase of the first project. By the end of this chapter, you will have your first completed game. Once you have Timber!!! up and running, be sure to read the last section of this chapter as it will suggest ways to make the game better:
Chapter 6, Object-Oriented Programming, Classes, and SFML Views, this is the longest chapter of the book. There is a fair amount of theory, but the theory will give us the knowledge to start using OOP (object-oriented programming) to great effect. Furthermore, we will not waste any time in putting that theory to good use. Before we explore C++ OOP, we will find out about and plan our next game project. This is what we will do:
Chapter 7, C++ References, Sprite Sheets, and Vertex Arrays , in this chapter, we will explore C++ references, which allow us to work on variables and objects that are otherwise out of scope. In addition, references will help us avoid having to pass large objects between functions, which is a slow process. It is a slow process because each time we do this, a copy of the variable or object must be made.
Armed with this new knowledge about references, we will take a look at the SFML VertexArray
class, which allows us to build up a large image that can be very quickly and efficiently drawn to the screen using multiple images from a single image file. By the end of the chapter, we will have a scaleable, random, scrolling background, using references and a VertexArray
object.
We will now talk about:
VertexArrays
Chapter 8, Pointers, the Standard Template Library, and Texture Management, we will learn a lot, as well as get plenty done to the game, in this chapter. We will first learn about the fundamental C++ topic of pointers. Pointers are variables that hold memory addresses. Typically, a pointer will hold the memory address of another variable. This sounds a bit like a reference, but we will see how they are much more powerful and we will use a pointer to handle an ever-expanding horde of zombies.
We will also learn about the Standard Template Library (STL), which is a collection of classes that allow us to quickly and easily implement common data management techniques.
Once we understand the basics of the STL, we will be able to use that new knowledge to manage all the textures from the game, because if we have 1,000 zombies, we don't really want to load a copy of a zombie graphic into the GPU for each and every one.
We will also dig a little deeper into OOP and use a static function, which is a function of a class that can be called without an instance of the class. At the same time, we will see how we can design a class to ensure that only one instance can ever exist. This is ideal when we need to guarantee that different parts of our code will use the same data.
In this chapter we will:
Chapter 9, Collision Detection, Pickups, and Bullets, so far, we have implemented the main visual parts of our game. We have a controllable character running around in an arena full of zombies that chase him. The problem is that they don't interact with each other. A zombie can wander right through the player without leaving a scratch. We need to detect collisions between the zombies and the player.
If the zombies are going to be able to injure and eventually kill the player, it is only fair that we give the player some bullets for his gun. We will then need to make sure that the bullets can hit and kill the zombies.
At the same time, if we are writing collision detection code for bullets, zombies, and the player, it would be a good time to add a class for health and ammo pickups as well.
Here is what we will do and the order we will cover things:
Chapter 10, Layering Views and Implementing the HUD, in this chapter, we will get to see the real value of SFML Views. We will add a large array of SFML Text objects and manipulate them as we did before in the Timber!!! project. What is new is that we will draw the HUD using a second View instance. This way the HUD will stay neatly positioned over the top of the main game action, regardless of what the background, player, zombies, and other game objects are doing.
Here is what we will do:
Chapter 11, Sound Effects, File I/O, and Finishing the Game, we are nearly there. This short chapter will demonstrate how we can easily manipulate files stored on the hard drive using the C++ standard library, and we will also add sound effects. Of course, we know how to add sound effects but we will discuss exactly where in the code the calls to play
will go. We will also tie up a few loose ends to make the game complete. In this chapter we will do the following:
Chapter 12, Abstraction and Code Management – Making Better Use of OOP, in this chapter, we will take a first look at the final project of the book. The project will have advanced features, such as directional sound that comes out of the speakers relative to the position of the player. It will also have split-screen co-operative gameplay. In addition, this project will introduce the concept of Shaders which are programs written in another language that run directly on the graphics card. By the end of Chapter 16: Extending SFML Classes, Particle Systems and Shaders, you will have a fully functioning, multiplayer platform game built in the style of the hit classic Thomas Was Alone. This chapter's main focus will be getting the project started, especially exploring how the code will be structured to make better use of OOP. Here are the details of this chapter.
Chapter 13, Advanced OOP – Inheritance and Polymorphism, in this chapter, we will further extend our knowledge of OOP by looking at the slightly more advanced concepts of inheritance and polymorphism. We will then be able to use this new knowledge to implement the star characters of our game, Thomas and Bob. Here is what we will cover, in a little more detail:
PlayableCharacter
classThomas
and Bob
classesChapter 14, Building Playable Levels and Collision Detection, this chapter will probably be one of the most satisfying of this project. The reason for this is that by the end of it we will have a playable game. Although there will be features still to implement (sound, particle effects, HUD, shader effects), Bob and Thomas will be able to run, jump, and explore the world. Furthermore, you will be able to create your very own level designs of almost any size or complexity, by simply making platforms and obstacles in a text file. We will achieve all this by covering these topics:
LevelManager
class that will load levels from a text file, convert them into data our game can use, and keep track of the level details such as spawn position, current level, and allowed time limitLevelManager
Chapter 15, Sound Spatialization and HUD, in this chapter we will be adding all the sound effects and the HUD. We have done this in both of the previous projects, but we will do things a bit differently this time. We will explore the concept of sound spatialization and how SFML makes this otherwise complicated concept nice and easy; in addition, we will build a HUD class to encapsulate our code draws information to the screen.
We will complete these tasks in this order:
SoundManager
classSoundManager
classHUD
classHUD
class
Chapter 16, Extending SFML Classes, Particle Systems, and Shaders, in this final chapter, we will explore the C++ concept of extending other people's classes. More specifically, we will look at the SFML Drawable
class and the benefits of using it as a base class for our own classes. We will also scratch the surface of the topic of OpenGL Shaders and see how writing code in another language (GLSL), which can be run directly on the graphics card, can lead to smooth graphical effects that might otherwise be impossible. As usual, we will also use our new skills and knowledge to enhance the current project.
Here is a list of the topics in the order we will cover them:
Chapter 17, Before You Go..., a quick discussion of what you might like to do next.
18.191.202.240