Online · Taipa · Macau

Scratch Game Design and Logic Coding Classes in Taipa, Macau

Scratch game design and logic coding classes for Taipa, Macau teach collision detection, score variables, multi-level maps and character animation so children build fully playable 2D games.

Scratch Taipa

1. Introduction: What Does "Instance" Mean in OOP?

In previous modules, we established that in Object-Oriented Programming (OOP), we organize our code around objects. Before creating objects, we first design an abstract blueprint or template known as a Class, from which we can instantiate as many objects as desired.

In Python OOP, the term "instance" simply means an object created from a class.

  • The Class serves as the abstract template.
  • The Instance is the concrete, individual object instantiated from that template.

The core purpose of instantiating multiple objects from a single class is that each individual object possesses its own distinct data attributes and its own methods.

The Real-World Analogy: Automobiles

Consider a Car class. When manufacturing multiple cars from that blueprint, each individual car object has its own distinct brand, color, size, and engine specifications. When an acceleration method is called on a specific car, the resulting speed depends directly on that specific car's own horsepower and engine capacity (CC).

In the real world, entities interact through their own independent properties. OOP mirrors this reality: every object accesses its own internal data and its own methods, making software systems behave like real-world entities.

2. Instance Variables: Defined via self.

Instance variables are variables that belong specifically to a particular object instance.

  • How to identify an instance variable: Every instance variable is prefixed with the keyword self. (e.g., self.name, self.age, self.grade).
  • Initialization in the constructor: Instance variables are typically initialized inside the __init__ constructor method by binding incoming input arguments to the instance using self.:
self.name = name
self.age = age
self.grade = grade

Why self is essential: A class is merely an abstract template with no physical existence in memory. Physical existence belongs solely to the created object instances. The self keyword ensures Python knows which specific object's data attribute is being created, modified, or retrieved.

3. Instance Methods: Defined with the self Parameter

Instance methods are functions defined inside a class that operate directly on that specific object's instance variables.

  • How to identify an instance method: Any method that includes self as its first parameter is an instance method.
  • The role of self: When an instance method is called, self represents the specific object on which the function was invoked, allowing the method to access that object's instance variables directly (e.g., reading self.name or self.age).
  • Omitting self: If you do not include the self parameter, the method or attribute will not belong to that particular object instance.
  • Full programming logic inside methods: Just like standard procedural programming, you can embed any control flow inside instance methods—including if conditional statements, loops, and calculations.

4. Practical Jupyter Notebook Implementation: The Student Class

Below is the complete implementation of the Student class demonstrating both instance variables and instance methods:

class Student:
    # 1. Constructor initializing instance variables
    def __init__(self, name, age, grade):
        self.name = name          # Instance variable for student's name
        self.age = age            # Instance variable for student's age
        self.grade = grade        # Instance variable for student's grade

    # 2. Instance method to display the student's attributes
    def display_info(self):
        # Accessing instance variables via self.
        print("Name:", self.name)
        print("Age:", self.age)
        print("Grade:", self.grade)

    # 3. Instance method with conditional logic checking admission eligibility
    def is_eligible(self):
        if self.age > 15:
            print(f"{self.name} is eligible for admission.")
        else:
            print(f"{self.name} is not eligible for admission.")

5. Instantiating Objects and Calling Instance Methods

Once the class template is defined, we can instantiate multiple student objects with distinct data:

# Creating student1 (Age 16 — greater than 15)
student1 = Student("Ali", 16, "A")

# Creating student2 (Age 14 — less than 15)
student2 = Student("Sara", 14, "B")

# Calling instance methods on student1
print("--- Student 1 Details ---")
student1.display_info()
student1.is_eligible()

# Calling instance methods on student2
print("\n--- Student 2 Details ---")
student2.display_info()
student2.is_eligible()

Execution Output:

--- Student 1 Details ---
Name: Ali
Age: 16
Grade: A
Ali is eligible for admission.

--- Student 2 Details ---
Name: Sara
Age: 14
Grade: B
Sara is not eligible for admission.

Execution Walkthrough

  1. Targeted data access: When student1.display_info() executes, self points to student1, correctly printing "Ali", 16, and "A".
  2. Dynamic decision making: In the is_eligible() method:
    • For student1, self.age is 16. Because 16 > 15 evaluates to True, it outputs that Ali is eligible for admission.
    • For student2, self.age is 14. Because 14 > 15 is False, it outputs that Sara is not eligible for admission.
  3. Each object maintains its own data state and behaves independently.

Lesson Q&A

In Python Object-Oriented Programming, an instance refers to a concrete object created from a class template. Instance variables are variables that belong specifically to a given object instance. When multiple objects are created from the same class blueprint (such as two different Car or Student objects), each instance maintains its own independent variables and values (for example, each car has its own distinct color, brand, and engine size). One object accessing or updating its instance variables has no effect on any other object's data.

Instance variables are identified by the self. keyword preceding the variable name (e.g., self.name, self.age, self.grade). This binds the data attribute directly to the specific object instance. Instance methods are identified by having self as their first parameter (e.g., def display_info(self): or def is_eligible(self):). This parameter allows the method to identify which object called it and access that object's internal attributes. If self is omitted, the method or attribute does not belong to that particular object instance.

Because a class template is an abstract structure that has no physical memory of its own, self identifies the exact physical object calling the method. When an instance method contains conditional logic—such as checking whether a student is eligible for admission (if self.age > 15:)—self.age dynamically pulls the age attribute belonging to the calling object. If called by an object with age 16, the condition evaluates to True; if called by an object with age 14, the condition evaluates to False, allowing the same method template to produce object-specific decisions.

What children can learn

WhatsApp +92 322 421 7059

AI and Robotics Club | The 100 Mission AI & Robotics Hero Journey

Recommended self-paced course for parents & educators

Scratch by MIT Programming for Kids on Udemy.

Disclosure: This page contains affiliate links. We may earn from qualifying purchases at no extra cost to you. Links are intended for parents and educators, not as marketing directed at young children.

From Player to Designer: Game Logic for Taipa Young Coders

Taipa families can convert gaming interest into structured logic practice. Enquire WhatsApp +92 322 4217059. No invented Taipa studio.

Frequently asked questions

What game design concepts will children in Taipa, Macau learn in this Scratch course?

Students in Taipa learn collision detection, score variables, gravity simulation, multi-level map design, and character animation algorithms to build fully playable 2D games from scratch.

How does this course turn computer gaming habits into an educational advantage?

Instead of passively consuming video games, students analyze game mechanics from a software engineer's perspective, developing computational logic and structural thinking while having fun.

What is the procedure for booking a free Scratch game design trial in Taipa?

Send a message via WhatsApp to our admissions desk, choose your preferred weekend or weekday evening slot, and claim a free 1-on-1 trial class pass today.

Explore related learning

Macau PeninsulaSTEM Club · Macau Peninsula Mid-LevelsScratch · Mid-Levels HK CentralRobotics · Central HK