Beginning C++ game programming learn C++ from scratch and get started building your very own games

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 wi...

Descripción completa

Detalles Bibliográficos
Otros Autores: Horton, John, 1920- author (author)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham, England : Packt Publishing 2016.
Edición:1st edition
Colección:Community experience distilled.
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009630151106719
Tabla de Contenidos:
  • Cover
  • Credits
  • About the Author
  • Copyright
  • About the Reviewer
  • www.PacktPub.com
  • Table of Contents
  • Preface
  • Chapter 1: C++, SFML, Visual Studio, and Starting the First Game
  • The games
  • Timber!!!
  • Zombie Arena
  • Thomas was Late
  • Meet C++
  • Microsoft Visual Studio
  • SFML
  • Setting up the development environment
  • What about Mac and Linux?
  • Installing Visual Studio Express 2015 on your desktop
  • Setting up SFML
  • Creating a reusable project template
  • Planning Timber!!!
  • Creating a project from the template
  • Project assets
  • Outsourcing assets
  • Making your own sound FX
  • Adding assets to the project
  • Exploring assets
  • Understanding screen and internal coordinates
  • Starting to code the game
  • Making code clearer with comments
  • #including Windows essentials
  • The main function
  • Presentation and syntax
  • Returning values from a function
  • Running the game
  • Opening a window using SFML
  • #including SFML features
  • OOP, classes, objects
  • Using namespace sf
  • SFML VideoMode and RenderWindow
  • Running the game
  • The main game loop
  • While loops
  • C-style code comments
  • Input, update, draw, repeat
  • Detecting a key press
  • Clearing and drawing the scene
  • Running the game
  • Drawing the game background
  • Preparing the sprite using a texture
  • Double-buffering the background sprite
  • Running the game
  • Handling errors
  • Configuration errors
  • Compile errors
  • Link errors
  • Bugs
  • FAQ
  • Summary
  • Chapter 2: Variables, Operators, and Decisions - Animating Sprites
  • C++ variables
  • Types of variable
  • Constants
  • User-defined types
  • Declaring and initializing variables
  • Declaring variables
  • Initializing variables
  • Declaring and initializing in one step
  • Declaring and initializing user-defined types
  • Manipulating variables.
  • C++ arithmetic and assignment operators
  • Getting things done with expressions
  • Adding clouds, a tree, and a buzzing bee
  • Preparing the tree
  • Preparing the bee
  • Preparing the clouds
  • Drawing the tree, the bee, and the clouds
  • Random numbers
  • Generating random numbers in C++
  • Making decisions with if and else
  • Logical operators
  • C++ if and else
  • If they come over the bridge, shoot them!
  • Or do this instead
  • Reader challenge
  • Timing
  • The frame-rate problem
  • The SFML frame-rate solution
  • Moving the clouds and the bee
  • Giving life to the bee
  • Blowing the clouds
  • FAQ
  • Summary
  • Chapter 3: C++ Strings, SFML Time, Player Input, and HUD
  • Pausing and restarting the game
  • C++ strings
  • Declaring strings
  • Assigning a value to strings
  • Manipulating strings
  • SFML Text and Font
  • Adding a score and a message
  • Adding a time bar
  • FAQ
  • Summary
  • Chapter 4: Loops, Arrays, Switch, Enumerations, and Functions - Implementing Game Mechanics
  • Loops
  • while loops
  • Breaking out of a while loop
  • for loops
  • Arrays
  • Declaring an array
  • Initializing the elements of an array
  • Quickly initializing the elements of an array
  • So what do these arrays really do for our games?
  • Making decisions with switch
  • Class enumerations
  • Getting started with functions
  • Function return types
  • Function names
  • Function parameters
  • The function body
  • Function prototypes
  • Organizing functions
  • Function gotcha!
  • Final word on functions - for now
  • Absolute final word on functions - for now
  • Growing the branches
  • Preparing the branches
  • Updating the branch sprites each frame
  • Drawing the branches
  • Moving the branches
  • FAQ
  • Summary
  • Chapter 5: Collisions, Sound, and End Conditions - Making the Game Playable
  • Preparing the player (and other sprites).
  • Drawing the player and other sprites
  • Handling the player's input
  • Handling setting up a new game
  • Detecting the player chopping
  • Detecting a key being released
  • Animating the chopped logs and the ax
  • Handling death
  • Simple sound FX
  • How SFML sound works?
  • When to play the sounds
  • Adding the sound code
  • Improving the game and the code
  • FAQ
  • Summary
  • Chapter 6: Object-Oriented Programming, Classes, and SFML Views
  • Planning and starting the Zombie Arena game
  • Creating a project from the template
  • The project assets
  • Exploring the assets
  • Adding the assets to the project
  • OOP
  • What is OOP?
  • Encapsulation
  • Polymorphism
  • Inheritance
  • Why do it like this?
  • What is a class?
  • The class variable and function declarations
  • The class function definitions
  • Using an instance of a class
  • Constructors and getter functions
  • Jumping around in the code
  • Building the Player-the first class
  • Coding the Player class header file
  • Coding the Player class function definitions
  • Controlling the game camera with SFML View
  • Starting the Zombie Arena game engine
  • Managing the code files
  • Starting coding the main game loop
  • FAQ
  • Summary
  • Chapter 7: C++ References, Sprite Sheets, and Vertex Arrays
  • C++ References
  • References summary
  • SFML vertex arrays and sprite sheets
  • What is a sprite sheet?
  • What is a vertex array?
  • Building a background from tiles
  • Building a vertex array
  • Using the vertex array to draw
  • Creating a randomly generated scrolling background
  • Using the background
  • FAQ
  • Summary
  • Chapter 8: Pointers, the Standard Template Library, and Texture Management
  • Pointers
  • Pointer syntax
  • Declaring a pointer
  • Initializing a pointer
  • Reinitializing pointers
  • Dereferencing a pointer
  • Pointers are versatile and powerful
  • Dynamically allocated memory.
  • Passing a pointer to a function
  • Declaring and using a pointer to an object
  • Pointers and arrays
  • Summary of pointers
  • The Standard Template Library
  • What is a Map
  • Declaring a Map
  • Adding data to a Map
  • Finding data in a Map
  • Removing data from a Map
  • Checking the size of a Map
  • Checking for keys in a Map
  • Looping/iterating through the key-value pairs of a Map
  • The auto keyword
  • STL summary
  • The TextureHolder Class
  • Coding the TextureHolder header file
  • Coding the TextureHolder function definitions
  • What exactly have we achieved with TextureHolder?
  • Building a horde of zombies
  • Coding the Zombie.h file
  • Coding the Zombie.cpp file
  • Using the Zombie class to create a horde
  • Bringing the horde to life (back to life)
  • Using the TextureHolder class for all textures
  • Change the way the background gets its textures
  • Change the way Player gets its texture
  • FAQ
  • Summary
  • Chapter 9: Collision Detection, Pickups, and Bullets
  • Coding the Bullet class
  • Coding the Bullet header file
  • Coding the Bullet source file
  • Making the bullets fly
  • Including the Bullet class
  • Control variables and the bullet array
  • Reloading the gun
  • Shooting a bullet
  • Updating the bullets each frame
  • Drawing the bullets each frame
  • Giving the player a crosshair
  • Coding a class for pickups
  • Coding the Pickup header file
  • Coding the Pickup class function definitions
  • Using the Pickup class
  • Detecting collisions
  • Has a zombie been shot?
  • Has the player been touched by a zombie?
  • Has the player touched a pickup?
  • FAQ
  • Summary
  • Chapter 10: Layering Views and Implementing the HUD
  • Adding all the Text and HUD objects
  • Updating the HUD each frame
  • Drawing the HUD, and the home and level up screens
  • FAQ
  • Summary
  • Chapter 11: Sound Effects, File I/O, and Finishing the Game.
  • Saving and loading the high-score
  • Preparing sound effects
  • Leveling up
  • Restarting the game
  • Playing the rest of the sounds
  • Adding sound effects while the player is reloading
  • Make a shooting sound
  • Play a sound when the player is hit
  • Play a sound when getting a pickup
  • Make a splat sound when a zombie is shot
  • FAQ
  • Summary
  • Chapter 12: Abstraction and Code Management - Making Better Use of OOP
  • The Thomas Was Late game
  • Features of Thomas Was Late
  • Creating a project from the template
  • The project assets
  • Game level designs
  • GLSL Shaders
  • The graphical assets close-up
  • The sound assets close-up
  • Adding the assets to the project
  • Structuring the Thomas Was Late code
  • Building the game engine
  • Reusing the TextureHolder class
  • Coding Engine.h
  • Coding Engine.cpp
  • Coding the Engine class constructor definition
  • Coding the run function definition
  • Coding the input function definition
  • Coding the update function definition
  • Coding the draw function definition
  • The Engine class so far
  • Coding the main function
  • FAQ
  • Summary
  • Chapter 13: Advanced OOP - Inheritance and Polymorphism
  • Inheritance
  • Extending a class
  • Polymorphism
  • Abstract classes - virtual and pure virtual functions
  • Building the PlayableCharacter class
  • Coding PlayableCharacter.h
  • Coding PlayableCharacter.cpp
  • Building the Thomas and Bob classes
  • Coding Thomas.h
  • Coding Thomas.cpp
  • Coding Bob.h
  • Coding Bob.cpp
  • Updating the game engine to use Thomas and Bob
  • Updating Engine.h to add an instance of Bob and Thomas
  • Updating the input function to control Thomas and Bob
  • Updating the update function to spawn and update the PlayableCharacter instances
  • Spawning Thomas and Bob
  • Updating Thomas and Bob each frame
  • Drawing Bob and Thomas
  • FAQ
  • Summary.
  • Chapter 14: Building Playable Levels and Collision Detection.