OOP primer
So far in this chapter, we have learned about functions, classes, and objects. These concepts are very powerful: they give us a completely different way of working with data and the logic that accompanies it.
In programming, there are multiple different paradigms of structuring code and data, one of them is Object Oriented Programming (OOP). GDScript is an object-oriented (OO) and imperative programming language, which means that we group data and its accompanying logic within classes and objects. The logic we write consists of statements that tell the computer fairly exactly what to do and how to do it for us. Each statement changes the internal state of the program. Most game engines and their accompanying programming languages are OO and imperative.
OOP is built upon four key principles: inheritance, abstraction, encapsulation, and polymorphism. So, let’s have a look at these.
Inheritance
OOP allows classes to inherit from one another. This means that...