Reader small image

You're reading from  Learning Construct 2

Product typeBook
Published inDec 2014
Reading LevelIntermediate
Publisher
ISBN-139781784397678
Edition1st Edition
Languages
Right arrow
Author (1)
Aryadi Subagio
Aryadi Subagio
author image
Aryadi Subagio

Aryadi Subagio is the second among seven brothers. He has loved video games ever since he was little, and he wanted to make his own game in his teenage years. This led him to pursue a Diploma in Computer Programming after he graduated from high school, where he spent years learning about software development techniques. He learned about game development from online sites, because at that time, there was no book on game development in Indonesia. After graduating, he immediately jumped into the world of game development. During this time, he made a few shooting games for the Flash Platform. After a year, he decided to gain more experience by working in a game studio; this is when he joined Esabra Studio. After working at Esabra Studio, he worked at Enthrean Guardian, a game studio based in Semarang. He has now quit working and is trying to set up his own studio. Aryadi has a passion for sharing his knowledge. He has written a lot of blog posts about game development on Indonesian and English sites. He also shares his knowledge on his own personal blog at http://daggio21.blogspot.com/.
Read more about Aryadi Subagio

Right arrow

Chapter 8. Debugging Your Game

Up until now, you have learned how to make games. You now know how to use Construct 2's interfaces and how to work with them, and you also know how to use the event system to write your code and expressions. Moreover, you know how to use behaviors in objects.

However, we most likely won't write the correct code on the first try. In fact, in all the previous chapters, I corrected the code first before presenting it to you so that you only saw the good code. But now, we will write code a bit differently. I will show you the kind of situations that cause bugs to appear and how to handle them.

In this chapter, you will:

  • Learn how to use the debugging function of Construct 2

  • Find out what situations usually cause bugs

  • Understand more about how Construct 2 picks objects

Bugs and their types


There are actually two kinds of bugs that appear in a game: the compile time bug and the runtime bug. The compile time bug is the bug that is detected by Construct 2 (or any other programming tools) when the code is being translated into a game or when it is being compiled. On the other hand, the runtime bug is the bug that is not detected when compiled, but comes up while the game is played.

The compile time bug usually appears because there's some code that's not written correctly, or, maybe, we're trying to access a variable that has not been created yet. Usually, there's no compile time bug in Construct 2, because it is designed to be beginner-friendly, and you can't do something impossible such as accessing a variable that doesn't exist.

Solving a runtime bug

Alright, so what usually causes runtime bugs to appear in Construct 2? Bugs appear when we do not write code clear enough for Construct 2 to understand. Let's say you're writing the code that runs at the beginning...

Using Construct 2's debugging tool


Now, we know enough to be careful when writing our code so that we can evade the runtime bug. However, sometimes, there are bugs that we didn't anticipate, no matter how careful we are in writing our code. In times like these, we need to be able to see how Construct 2 runs our game behind the curtains. This is where we need the debugging tool.

Note

While you can use the debugging tool in the free version of Construct 2, some features are only available to the users who have bought the licensed version. I will inform you what these features are when we discuss them.

Using the inspector

You can use the debugging tool primarily by debugging each layout. To do this, just click on the Debug layout button right beside the Run layout button at the top of Construct 2:

Clicking on it will start the game as usual, except that you'll also see the debug tool (called the Inspector tab) below the game. On the left-hand side of the debugging tool, you'll see a list of all...

Different levels of bug importance


Before I wrap up this chapter, it is a good idea to discuss the levels of bug importance. Most game developers use this to categorize the bugs they encounter in their games and use this as a basis for which bugs to take care of first. These levels, ordered from most important to least, are as follows:

  • Critical bugs: These are bugs that make the game freeze or crash or else make it impossible for the player to continue the game. These bugs can prevent the next level from loading or prevent the Play button on the title screen from working.

  • Major bugs: These are bugs that make it very difficult for the player to play the game. These can come in the form of the character that randomly stops attacking, a certain ability that doesn't work, or an enemy that doesn't die when its HP (Health Points) reaches zero.

  • Minor bugs: These are bugs that don't cause any trouble in the gaming experience but are still very noticeable. These bugs can include the wrong graphic showing...

Summary


You learned some important skills in this chapter. You know how picking works in Construct 2. You learned about the kinds of events that might cause a bug, and you also learned how to evade it. You also know in detail about the Construct 2 debugging tool and how to use it, including the more advanced breakpoints feature.

Knowing how to debug your game is really useful, but wouldn't it be better if we can write good code from the beginning? In the next chapter, we'll learn the best practices in Construct 2, whether that's about evading bugs or improving the performance of your game.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning Construct 2
Published in: Dec 2014Publisher: ISBN-13: 9781784397678
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.
undefined
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 $15.99/month. Cancel anytime

Author (1)

author image
Aryadi Subagio

Aryadi Subagio is the second among seven brothers. He has loved video games ever since he was little, and he wanted to make his own game in his teenage years. This led him to pursue a Diploma in Computer Programming after he graduated from high school, where he spent years learning about software development techniques. He learned about game development from online sites, because at that time, there was no book on game development in Indonesia. After graduating, he immediately jumped into the world of game development. During this time, he made a few shooting games for the Flash Platform. After a year, he decided to gain more experience by working in a game studio; this is when he joined Esabra Studio. After working at Esabra Studio, he worked at Enthrean Guardian, a game studio based in Semarang. He has now quit working and is trying to set up his own studio. Aryadi has a passion for sharing his knowledge. He has written a lot of blog posts about game development on Indonesian and English sites. He also shares his knowledge on his own personal blog at http://daggio21.blogspot.com/.
Read more about Aryadi Subagio