Making new fruits is easy because of inheritance
Inheritance in game development is an object-oriented programming (OOP) principle where a specialized "child" class inherits properties and behaviors (methods) from a general "parent" (base) class. It reduces code duplication by enabling shared functionality—like health, movement, or damage—to be written once in a base class and reused across many specific, derived classes.
An inherited scene in Godot is a specialized scene that derives its node structure and property values from a "parent" (or base) scene. Any modifications made to the parent scene—such as adding nodes or changing properties—are automatically propagated to the inherited child scene, allowing for efficient, DRY (Don't Repeat Yourself) workflow.
For our fruit, all behaviour is the same as that of the apple, the only change is to the sprite - visually each fruit looks different.
Select the Fruit.tscn file in FileManager
Right click it and choose New Inherited Scene
Now you a duplicate of the Fruit Scene
Everything under the Root node is Orange
This is an indication that you are working
Rename the root node to whichever fruit this is
I have chosen a Watermelon
Save it as that fruit name (watermelon.tscn)
Now, change the texture property of
ALL of the Sprite2Ds to match the fruit
Repeat this entire process for each fruit you want to add to the game.