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

Drawing the player and other sprites


Before we add the code to move the player and use all our new sprites, let's draw them. This is so that, as we add code to update/change/move the sprites, we will be able to see what is happening.

Add the highlighted code to draw the four new sprites:

// Draw the tree 
window.draw(spriteTree); 
 
// Draw the player 
window.draw(spritePlayer); 
 
// Draw the axe 
window.draw(spriteAxe); 
 
// Draraw the flying log 
window.draw(spriteLog); 
 
// Draw the gravestone 
window.draw(spriteRIP); 
 
// Draw the bee 
window.draw(spriteBee); 

Run the game and you will see our new sprites in the scene.

We are really close to a working game now.