Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Beginning C++ Game Programming

You're reading from   Beginning C++ Game Programming Learn C++ from scratch and get started building your very own games

Arrow left icon
Product type Paperback
Published in Oct 2016
Publisher Packt
ISBN-13 9781786466198
Length 520 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
John Horton John Horton
Author Profile Icon John Horton
John Horton
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. C++, SFML, Visual Studio, and Starting the First Game FREE CHAPTER 2. Variables, Operators, and Decisions – Animating Sprites 3. C++ Strings, SFML Time, Player Input, and HUD 4. Loops, Arrays, Switch, Enumerations, and Functions – Implementing Game Mechanics 5. Collisions, Sound, and End Conditions – Making the Game Playable 6. Object-Oriented Programming, Classes, and SFML Views 7. C++ References, Sprite Sheets, and Vertex Arrays 8. Pointers, the Standard Template Library, and Texture Management 9. Collision Detection, Pickups, and Bullets 10. Layering Views and Implementing the HUD 11. Sound Effects, File I/O, and Finishing the Game 12. Abstraction and Code Management – Making Better Use of OOP 13. Advanced OOP – Inheritance and Polymorphism 14. Building Playable Levels and Collision Detection 15. Sound Spatialization and HUD 16. Extending SFML Classes, Particle Systems, and Shaders 17. Before you go...

Handling errors

There will always be problems and errors in every project you make, that is guaranteed! The tougher a problem is, the more satisfying it is when you solve it. When, after hours of struggling, a new game feature finally bursts into life, it can cause a genuine high. Without the struggle, it would somehow be less worthwhile.

At some point in this book there will probably be some struggle. Remain calm, be confident that you will overcome it, and then set to work.

Remember that, whatever your problem, it is very unlikely you are the first person in the world to have ever had this same problem. Think of a concise sentence that describes your problem or error and then type it in to Google. You will be surprised how quickly, precisely, and often, someone else will already have solved your problem for you.

Having said that, here are a few pointers (pun intended; see Chapter 8: Pointers, Standard Template Library, and Texture Management) to get you started, in the event you are struggling with making this first chapter work.

Configuration errors

The most likely cause of problems in this chapter will be configuration errors. As you probably noticed during the process of setting up Visual Studio, SFML, the project template, and the project itself, there are an awful lot of filenames, folders, and settings that need to be just right. Just one wrong setting could cause one of a number of errors in which the text doesn't make it clear exactly what is wrong.

If you can't get the empty project with the black screen working in the Creating a reusable template section, it might be easier to start that section again. Make sure all the filenames and folders are appropriate for your specific setup and then get the simplest part of the code running (the part where the screen flashes black and then closes). If you can get to this stage, then configuration is probably not the issue.

Compile errors

Compile errors are probably the most common error we will experience going forward. Check that your code is identical to mine, especially semicolons on the ends of lines and subtle changes in upper and lower case for class and object names. If all else fails, open the code files in the download bundle and copy and paste it. While it is always possible that a code typo made it into the book, the code files were made from actual working projects - they definitely work!

Link errors

Link errors are most likely caused by missing SFML .dll files. Did you copy all of them into the project folder in the section Creating a project from the template?

Bugs

Bugs are what happen when your code works, but not as you expect it to. Debugging can actually be fun. The more bugs you squash the better your game and the more satisfying your day's work will be. The trick to solving bugs is to find them early! To do this I recommend running and playing your game every time you implement something new. The sooner you find the bug, the more likely the cause will be fresh in your mind. In this book we will run the code to see the results at every possible stage.

You have been reading a chapter from
Beginning C++ Game Programming
Published in: Oct 2016
Publisher: Packt
ISBN-13: 9781786466198
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime