Making decisions with Java
Our Java code will constantly be making decisions. For example, we might need to know if the player has been hit or if they have a certain number of power-ups. We need to be able to test our variables to see if they meet certain conditions and then execute a certain section of code, depending on whether it did or not.
In this chapter and the next, we will look at controlling the flow of execution of our game's code. This chapter, as its name suggests, will discuss fine control over repeating sections of code based on predetermined conditions, while the next chapter will look at branching to different sections of code, also based on predetermined conditions.
In the next two chapters, our code will become more in-depth, so it helps to present it in a way that makes it more readable. Let's take a look at code indenting to make our discussion easier.