2

Getting Familiar with Variables and Control Flow

Programming is all about manipulating data. In games, this data can be the position of the player, the amount of health they have, or what items they possess. These pieces of data are called variables, and in this chapter, we will learn how these variables work and how we can manipulate them.

In the second part of this chapter, we’ll learn how to use these variables to make decisions during the game. For example, if the health of the player goes to zero, we end the game. This concept is called control flow because we control the flow throughout the code.

In this chapter, we will cover the following main topics:

  • What are variables?
  • Data types – Integers, floats, and strings
  • What are constants? ...

Get Learning GDScript by Developing a Game with Godot 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.