Learn about the Zombie Arena game.
- [Instructor] Hi, and welcome to section six, Object-Oriented Programming, Classes, and SFML. In this section, we will be planning the zombie arena game, learning about OOP and classes, also about code, the player class. We will also learn about the SFML view class, build the zombie arena game engine, and finally, put the player class to work. Now we move on to the first video of this section that deals with planning and starting the zombie arena game. In this video, we are going to take a look at where we are going to generate a project, learn about project assets and explore them.
Then, we will add the assets to the project. At this point, if you haven't already, I suggest you go and watch a video of Over 9,000 Zombies on this URL. And Crimsonland game on this URL. Our game will obviously not be as in depth or advanced as either of the examples, but we will have the same basic set of features and game mechanics. A heads-up display, HUD, that shows details such as score, high score, bullets and clip, total bullets left, player health, and zombies left to kill. The player will shoot zombies while frantically running away from them, move around a scrolling world using the W, A, S, and D keys, while aiming the gun using the mouse.
In between each level, choose a level up that will affect the way the game needs to be played to succeed. Collect pick-ups to restore health and ammunition. Each wave brings more zombies and a bigger arena. There will be three types of zombie to splatter. They will have different attributes, such as appearance, health, and speed. We will call them chasers, blowers, and crawlers. Take a look at this annotated screenshot of the game to see some of the features in action, and the components and the assets that make up the game.
Here's a little bit more information about each of the points. The score and hi score, these, along with the other parts of the HUD, will be drawn in a separate layer known as a view. The hi score will be saved and loaded to a file. This is a texture that we'll build a wall around the arena. This texture is contained in a single graphic called a sprite-sheet, along with the other background textures, three, five, and six, the first of two mud textures from the sprite-sheet. This is an ammo pick-up.
When the player gets this, they will be given even more ammunition. There is a health pick-up as well. The players can choose to upgrade these pick-ups in between waves of zombies. A grass texture, also from the sprite-sheet, the second mud texture from the sprite-sheet, a blood splatter where there used to be a zombie. The bottom part of the HUD from left to right is an icon to represent ammo. The number of bullets in the clip, the number of spare bullets, a health bar, the current wave of zombies, and the number of zombies remaining in this wave.
The player character, a crosshair, which the player aims with the mouse, a strong moving, but strong bloater, zombie, a slightly faster moving but weaker crawler zombie. There's also a chaser zombie, who is very fast and weak. Here we have a lot to do and new C++ skills to learn. Let's start by creating a new project. Creating a new project is now extremely easy. First, select file. Then, new project from the main menu. Make sure the visual C++ is selected in the left hand menu, and then select HelloSFML from the list of presented options.
In the name field, type zombie arena, and also make sure that the create directory for solution option is checked. Now click okay. Now we need to copy the SFML DLL files into the main project directory. My main project directory is D, Visual Studio stuff, projects, zombie arena, zombie arena. This folder was created by a Visual Studio in the previous step. If you put your projects folder somewhere else, then perform the step there instead.
The files we need to copy into the projects folder are located in your SFML bin folder. Open a window for each of the two locations and highlight the required DLL files. Now copy and paste the highlighted files into the project. The project is now set up and ready to go. The assets in this product are more numerous and diverse than the previous game. The assets include, a font for the writing on the screen, sound effects for different actions, such as shooting, reloading, or getting hit by a zombie.
The graphical assets make up the parts of the screen that is our zombie arena game. Take a look at the graphical assets and it should be clear where in our game they will be used. What might be less obvious, however, is the background sheet png, which contains four different images. This is the sprite-sheet I mentioned previously and we will see how we can use one to save memory, and increase the speed of our game in section seven, C++ references, sprite-sheets, and vertex arrays. The sound files are all wav format.
These are files which contain the sound effects that we will play at certain events throughout the game. They are, hit wave, a sound that plays when a zombie comes into contact with the player. Pick-up wave, a sound that plays when the player touches, collects a health boost, pick-up. Power up wave, a sound that plays when the player chooses an attribute to increase, in between each wave of zombies. Reload wave, a satisfying click to let the player know they have loaded a fresh clip of ammunition.
Reloaded fail wave, a less satisfying sound that indicates failure to load new bullets. Shoot wave, a shooting sound. Splat wave, a sound like a zombie being hit by a bullet. Once you have decided which assets you will use, it is time to add them to the project. Where you are using your own, simply replace the appropriate sound, or in graphic, file with your own using exactly the same file ame that is used in this course. Browse the D Visual Studio stuff, project zombie arena, zombie arena.
Create three new folders within this folder and name them graphics, sound, and fonts. From the download bundle, top of the entire contents of section six, graphics into the D, Visual Studio stuff, projects, zombie arena, zombie arena, graphics folder. From the download bundle, copy the entire contents of section six, sound into the D, Visual Studio stuff, projects, zombie arena, zombie arena, sound folder. Now visit www.1001freefonts.com/zombie_webfont in your web browser and download the zombie control font.
Extract the contents of the zip download and add the zombie contrl TTFL file to the D Visual Studio stuff, projects zombie arena, zombie area, fonts folder. Now it's time to learn something more C++ so we can start writing the code for Zombie Arena. In this video, we have successfully planned and started the zombie arena game. In the next video, we will talk about object-oriented programming.
This course was created and produced by Packt Publishing. We are honored to host this training in our library.
- Creating the main game loop
- Drawing the game background
- Handling errors
- Manipulating C++ variables
- Randomizing numbers
- Making decisions with if, else, and switch
- Moving game objects
- Pausing and restarting games
- Adding scoring and messages
- Using class enumerations and arrays
- Adding sound effects
- Object-oriented programming in C++
- C++ references
- Texture management
- Collision detection
- Implementing the HUD
- Finishing the game