1 option
Beginning C++ Game Programming : Learn C++ from Scratch by Building Fun Games / John Horton.
- Format:
- Book
- Author/Creator:
- Horton, John, 1905-1989, author.
- Language:
- English
- Subjects (All):
- Video games--Programming.
- Video games.
- Physical Description:
- 1 online resource (649 pages)
- Edition:
- Third edition.
- Place of Publication:
- Birmingham, England : Packt Publishing, [2024]
- Summary:
- Get to grips with programming and game development techniques using C++ libraries and Visual Studio 2022 with this updated edition of the bestselling seriesPurchase the eBook for full-color content Key Features Create fun games in C++, with this up-to-date guide covering the latest features of C++20 and VS2022 Build clones of popular games such as a Timberman clone, a Pong game, a Zombie Survival Shooter, and a platform endless runner game Discover tips to expand your finished games by thinking critically, technically, and creatively Book Description Always dreamed of creating your own games? With the third edition of Beginning C++ Game Programming, you can turn that dream into reality! This beginner-friendly guide is updated and improved to include the latest features of VS 2022, SFML, and modern C++20 programming techniques. You'll get a fun introduction to game programming by building four fully playable games of increasing complexity. You'll build clones of popular games such as Timberman, Pong, a Zombie survival shooter, and an endless runner.The book starts by covering the basics of programming. You'll study key C++ topics, such as object-oriented programming (OOP) and C++ pointers and get acquainted with the Standard Template Library (STL). The book helps you learn about collision detection techniques and game physics by building a Pong game. As you build games, you'll also learn exciting game programming concepts such as vertex arrays, directional sound (spatialization), OpenGL programmable shaders, spawning objects, and much more. You'll dive deep into game mechanics and implement input handling, levelling up a character, and simple enemy AI. Finally, you'll explore game design patterns to enhance your C++ game programming skills.By the end of the book, you'll have gained the knowledge you need to build your own games with exciting features from scratch. What you will learn Set up your game project in VS 2022 and explore C++ libraries such as SFML Build games in C++ from the ground up, including graphics, physics, and input handling Implement core game concepts such as game animation, game physics, collision detection, scorekeeping, and game sound Implement automatically spawning objects and AI to create rich and engaging experiences Learn advanced game development concepts, such as OpenGL shaders, texture atlases, and parallax backgrounds Scale and reuse your game code with modern game programming design patterns Who this book is for This book is perfect for you if you have no C++ programming knowledge, you need a beginner-level refresher course, or you want to learn how to build games or just use games as an engaging way to learn C++. Whether you aspire to publish a game (perhaps on Steam) or just want to impress friends with your creations, you'll find this book useful ]]>
- Contents:
- Cover
- Copyright
- Contributors
- Preface
- Chapter 1: Welcome to Beginning C++ Game Programming Third Edition!
- The games we will build
- Timber!!!
- Pong
- Zombie Arena
- Platform game
- Why you should learn game programming using C++ in 2024
- SFML
- Microsoft Visual Studio
- What about Mac and Linux?
- Installing Visual Studio 2022
- Setting up SFML
- Creating a new project in Visual Studio 2022
- Configuring the project properties
- Planning Timber!!!
- The project assets
- Making your own sound FX
- Adding the assets to the project
- Exploring the assets
- Understanding screen and internal coordinates
- Getting started with coding the game
- Making code clearer with comments
- The main function
- Presentation and syntax
- Returning values from a function
- Running the game
- Opening a window using SFML
- Including SFML features
- OOP, classes, and objects
- Using namespace sf
- SFML VideoMode and RenderWindow
- The game loop
- while loops
- C-style code comments
- Input, update, draw, repeat
- Detecting a key press
- Clearing and drawing the scene
- Drawing the game's background
- Preparing the sprite using a texture
- Double buffering the background sprite
- Handling errors
- Configuration errors
- Compile errors
- Link errors
- Bugs
- Summary
- Frequently asked questions
- Chapter 2: Variables, Operators, and Decisions: Animating Sprites
- Learning all about C++ variables
- Types of variables
- User-defined types
- Declaring and initializing variables
- Declaring variables
- Initializing variables
- Declaring and initializing in one step
- Constants
- Uniform initialization
- Declaring and initializing user-defined types
- Seeing how to manipulate the variables
- C++ arithmetic and assignment operators.
- Getting things done with expressions
- Assignment
- Increment and decrement
- Adding clouds, a buzzing bee, and a tree
- 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!
- Else 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
- Frequently Asked Questions
- Chapter 3: C++ Strings, SFML Time: Player Input and HUD
- Pausing and restarting the game
- C++ strings
- Declaring strings
- Assigning a value to strings
- String Concatenation
- Getting the string length
- Manipulating strings another way with StringStream
- SFML Text and SFML Font
- Adding a score and a message
- Adding a time-bar
- Chapter 4: Loops, Arrays, Switch Conditions, Enumerations, and Functions: Implementing Game Mechanics
- Loops
- Breaking out of a loop
- for loops
- Arrays
- Declaring an array
- Initializing the elements of an array
- Quickly initializing the elements of an array
- What do these arrays really do for our games?
- Making decisions with switch
- Class enumerations
- Getting started with functions
- Who designed all this weird and frustrating syntax and why is it the way it is?
- Function return types
- Function names
- Function parameters
- The function body
- Function prototypes
- Organizing functions
- Function scope
- A final word on functions - for now
- Growing the branches
- Preparing the branches
- Updating the branch sprites in each frame
- Drawing the branches
- Moving the branches.
- 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 axe
- Handling death
- Simple sound effects
- How SFML sound works
- When to play the sounds
- Adding the sound code
- Improving the game and code
- Chapter 6: Object-Oriented Programming - Starting the Pong Game
- Object-oriented programming
- Encapsulation
- Polymorphism
- Inheritance
- Why use OOP?
- What exactly is a class?
- The theory of a Pong bat
- Declaring the class, variables, and functions
- The class function definitions
- Using an instance of a class
- Creating the Pong project
- Coding the Bat class
- Coding Bat.h
- Constructor functions
- Continuing with the Bat.h explanation
- Coding Bat.cpp
- Using the Bat class and coding the main function
- Chapter 7: AABB Collision Detection and Physics - Finishing the Pong Game
- Coding the Ball class
- Using the Ball class
- Collision detection and scoring
- Learning about the C++ spaceship operator
- Chapter 8: SFML Views - Starting the Zombie Shooter Game
- Planning and starting the Zombie Arena game
- Creating a new project
- OOP and the Zombie Arena project
- 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 to code the main game loop
- Chapter 9: C++ References, Sprite Sheets, and Vertex Arrays
- Understanding C++ references
- Summarizing references
- 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
- Chapter 10: Pointers, the Standard Template Library, and Texture Management
- Learning about 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
- Learning about the Standard Template Library
- What is a vector?
- Declaring a vector
- Adding data to a vector
- Accessing data in a vector
- Removing data from a vector
- Checking the size of a vector
- Looping/iterating through the elements of a vector
- 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
- Chapter 11: Coding the TextureHolder Class and Building a Horde of Zombies
- Implementing the TextureHolder class
- Coding the TextureHolder header file
- Coding the TextureHolder function definitions
- What 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 (or back to life)
- Using the TextureHolder class for all textures
- Changing the way the background gets its textures
- Changing the way the Player class gets its texture
- Chapter 12: Collision Detection, Pickups, and Bullets
- Coding the Bullet class
- Coding the Bullet header file
- Coding the Bullet source file
- Coding the shoot function
- Calculating the gradient in the shoot function
- Making the gradient positive in the shoot function
- Calculating the ratio between X and Y in the shoot function
- Finishing the shoot function explanation
- More bullet functions
- The Bullet class's update function
- Making the bullets fly
- Including the Bullet class
- Control variables and the bullet array
- Reloading the gun
- Shooting a bullet
- Updating the bullets in each frame
- Drawing the bullets in 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?
- Chapter 13: Layering Views and Implementing the HUD
- Adding all the Text and HUD objects
- Updating the HUD
- Drawing the HUD, home, and level-up screens
- Chapter 14: Sound Effects, File I/O, and Finishing the Game
- Saving and loading the high score
- Preparing sound effects
- Allowing the player to level up and spawning a new wave
- Restarting the game
- Playing the rest of the sounds
- Adding sound effects while the player is reloading
- Making a shooting sound
- Playing a sound when the player is hit
- Playing a sound when getting a pickup.
- Making a splat sound when a zombie is shot.
- Notes:
- Includes bibliographical references and index.
- Description based on publisher supplied metadata and other sources.
- Description based on print version record.
- ISBN:
- 1-83508-825-2
The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.