Book Image

Beginning C++ Game Programming

Book Image

Beginning C++ Game Programming

Overview of this book

This book is all about offering you a fun introduction to the world of game programming, C++, and the OpenGL-powered SFML using three fun, fully-playable games. These games are an addictive frantic two-button tapper, a multi-level zombie survival shooter, and a split-screen multiplayer puzzle-platformer. We will start with the very basics of programming, such as variables, loops, and conditions and you will become more skillful with each game as you move through the key C++ topics, such as OOP (Object-Orientated Programming), C++ pointers, and an introduction to the Standard Template Library. While building these games, you will also learn exciting game programming concepts like particle effects, directional sound (spatialization), OpenGL programmable Shaders, spawning thousands of objects, and more.
Table of Contents (24 chapters)
Beginning C++ Game Programming
Credits
About the Author
About the Reviewer
www.PacktPub.com
Dedication
Preface
17
Before you go...

OOP


OOP is a programming paradigm that we could consider almost the standard way to code. It is true there are non-OOP ways to code and there are even some non-OOP game coding languages and libraries. However, starting from scratch, as this book does, there is no reason to do things any other way. When the benefits of OOP become apparent you will never look back.

OOP will:

  • Make our code easier to manage, change, or update

  • Make our code quicker and more reliable to write

  • Make it possible to easily use other people's code (such as SFML)

We have already seen the third benefit in action. Let's look at the first two benefits by introducing a problem that needs solving. The problem we are faced with is the complexity of the current project. Let's consider just a single zombie and what we need to make it function in the game:

  • Horizontal and vertical position

  • Size

  • Direction it is facing

  • Different textures for each zombie type

  • Sprites

  • Different speeds for each zombie type

  • Different health for each zombie type...