
Programming is the backbone of game development. Understanding the basics of programming and the most commonly used paradigms is essential to creating effective and efficient games. In this section, we’ll explore the fundamentals of programming applied specifically to video games, providing a solid foundation for developers.
Variables:
Variables are containers that store data that can change during the execution of a program. In video games, variables are used to store information such as the player’s score, the position of objects, the character’s health, etc.
Data Types:

Control structures direct the flow of decisions and repeat actions.
– if: Executes a block of code if the condition is true.
– else: Runs a block of code if the if condition is false.
– switch: Select a block of code to run from multiple options.
Example in C#:

– for: Repeats a block of code a specific number of times.
– while: Repeats a block of code as long as the condition is true.
– do-while: Similar to while, but ensures that the block of code is executed at least once.
Example in C#:

Functions and Methods:
They are reusable blocks of code that perform a specific task. In object-oriented programming, methods are associated with objects and classes.
Definition and Use:

OOP Basics:
– Class: It is a template for creating objects, which defines attributes and methods.
– Object: It is an instance of a class.
Example in C#:

– It allows you to create new classes based on existing classes, inheriting their attributes and methods.
Example in C#:

3. Potting:
– Protects a class’s data by hiding it from the outside and providing controlled access methods.
Example in C#:

– Allows methods to be used in a derived class that has the same name as one in the base class, providing different behaviors.
Example in C#:

Basics:
Component-based programming focuses on composing objects by adding components that encapsulate specific behaviors. This paradigm is widely used in game engines such as Unity and Unreal Engine.
– These are functionality modules that can be added to in-game objects to define their behavior.
Example in Unity:

– Entity: It is an empty container to which components are added to define its behavior and attributes.
– System: Manages the behavior of a set of components, applying specific logic to them.
Example in Unity with ECS (Entity Component System):
