Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Beginning C++ Game Programming
  • Table Of Contents Toc
  • Feedback & Rating feedback
Beginning C++ Game Programming

Beginning C++ Game Programming

By : John Horton
4.3 (27)
close
close
Beginning C++ Game Programming

Beginning C++ Game Programming

4.3 (27)
By: John Horton

Overview of this book

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.
Table of Contents (24 chapters)
close
close
22
Other Books You May Enjoy
23
Index

Coding the factory to use all our new classes

The Factory is an important class. It will be where we create all our smart pointers to derived Update and Graphics instances. We will call all the constructors and assemble function implementations while sharing the various required pointers that we have been coding. For example, the Factory is where we will share the pointer to the player and the position of the platforms with the LevelUpdate instance.

Remembering the texture coordinates

First of all, we will add code to the Factory.h file. In the Factory.h file, add the following variables to the private section:

  const int PLAYER_TEX_LEFT = 0;
  const int PLAYER_TEX_TOP = 0;
  const int PLAYER_TEX_WIDTH = 80;
  const int PLAYER_TEX_HEIGHT = 96;
  const float CAM_VIEW_WIDTH = 300.f;
  const float CAM_SCREEN_RATIO_LEFT = 0.f;
  const float CAM_SCREEN_RATIO_TOP = 0.f;
  const float CAM_SCREEN_RATIO_WIDTH = 1.f;
  const float CAM_SCREEN_RATIO_HEIGHT = 1.f;
  const int CAM_TEX_LEFT...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY