Godot
Concepts
File System
The filesystem that Godot provides is res:// for resources such as static game files or assets and user:// for dynamic data such as generated map data or game saves. Addons should be placed in res://addons in your project. Godot converts resource files into its own format and are placed in the res://.import folder.
Objects
A Node is the building block of Godot; all scene objects in Godot are Nodes. Nodes have properties and functions and can emit signals which others can subscribe to. Nodes can be assigned as a child of another node and are arranged into a tree. A tree of nodes is referred to as a Scene. Active scenes that are loaded and in use are part of a Scene Tree. In addition to the hierarchy/inheritance model, nodes can also be organized by groups (eg. as groups of Enemies, Collectables, etc. which can be retrieved with get_tree().get_nodes_in_group("enemies")).
A scene is saved to a TSCN (text-scene) file.
Scene Tree
Godot maintains an active set of scenes called a Scene Tree. When scenes are added to the scene tree, all its nodes will be added. Child nodes are added after their parent node. The root node of the Scene Tree is up to you but must be of a Node2D for 2D scenes or Spatial for 3D scenes.
Control nodes are used for user interfaces and behave differently from Node2D. Controls should be placed in a separate tree, under a CanvasLayer node.
Code can get the SceneTree by calling get_tree().
Nodes also receive a enter_tree notification. Only when all nodes have been added will they then be ready.
2D
(0, 0) is the top left.
Sprite nodes are drawn in the order that they are traversed on the SceneTree. Traversal is done depth-first (TODO: is this right?), meaning the first objects in the tree are drawn first. To switch the draw order, based on its Y position on the screen, use a YSort node (Huh. does this call sort every time something needs to draw? How do we deal with specific ordering otherwise?).
Examples
Node
Example of signals
extends Node2D
signal got_hurt (damage)
onready var hitpoints = 10 setget set_hitpoints
func set_hitpoints( new_hp ):
var diff = new_hp - hitpoints
if diff < 0:
emit_signal("got_hurt", diff)
hitpoints = new_hp