Overview
Space Pong uses three main scene files: the game scene (game.tscn), the ball scene (ball.tscn), and the player scene (player.tscn). The game scene serves as the root, instantiating the ball and player as child nodes.
Scene Files
game.tscn Main game scene with walls and instances
ball.tscn Ball entity with physics and sprite
player.tscn Player paddle with collision shape
Main Game Scene
File : res://scenes/game.tscn
The main scene uses Godot scene format version 3 and loads 7 resources:
[ gd_scene load_steps = 7 format = 3 uid = "uid://cc4souncpsicv" ]
External Resources
The scene loads three external resources:
[ ext_resource type = "Texture2D" path = "res://sprites/Fundo6.png" id = "1_62qvw" ]
[ ext_resource type = "PackedScene" path = "res://scenes/player.tscn" id = "2_f1na5" ]
[ ext_resource type = "PackedScene" path = "res://scenes/ball.tscn" id = "3_r68vm" ]
Scene Hierarchy
Game (Node2D)
├── Background (Sprite2D)
├── Player (CharacterBody2D) [instanced]
├── Ball (CharacterBody2D) [instanced]
├── TopWall (StaticBody2D)
│ └── CollisionShape2D
├── LeftWall (StaticBody2D)
│ └── CollisionShape2D
├── RightWall (StaticBody2D)
│ └── CollisionShape2D
└── Hole (Area2D)
└── CollisionShape2D
Node Configuration
Background
The background uses Fundo6.png with custom scaling to fill the 460x720 viewport: position = Vector2 ( 229.25 , 359.063 )
scale = Vector2 ( 0.858333 , 0.760286 )
Player Instance
The player paddle is positioned at the bottom of the screen: position = Vector2 ( 173 , 625 )
Ball Instance
The ball starts slightly above the player: position = Vector2 ( 223 , 581 )
Collision Boundaries
Three StaticBody2D nodes define the play area boundaries:
[ node name = "TopWall" type = "StaticBody2D" ]
[ node name = "CollisionShape2D" type = "CollisionShape2D" parent = "TopWall" ]
position = Vector2 ( 218 , - 26 )
shape = SubResource ( "RectangleShape2D_hb7cy" ) # Size: 497.5 x 63
The walls use RectangleShape2D collision shapes to create a bounded play area. The ball bounces off these walls during gameplay.
Game Over Detection
An Area2D node at the bottom detects when the ball falls off screen:
[ node name = "Hole" type = "Area2D" ]
[ node name = "CollisionShape2D" type = "CollisionShape2D" parent = "Hole" ]
position = Vector2 ( 221 , 749.375 )
shape = SubResource ( "RectangleShape2D_6aq72" ) # Size: 492 x 85.25
debug_color = Color ( 0.972549 , 0 , 0 , 0.419608 ) # Red debug visualization
The “Hole” area is positioned below the visible screen to trigger game over when the ball enters it.
Ball Scene
File : res://scenes/ball.tscn
The ball scene is a self-contained entity with physics simulation:
[ gd_scene load_steps = 4 format = 3 uid = "uid://bh8d61b0k4152" ]
[ ext_resource type = "Texture2D" path = "res://sprites/Bola.png" id = "1_jsy0t" ]
[ ext_resource type = "Script" path = "res://scenes/ball.gd" id = "1_wmsuy" ]
Node Structure
Ball (CharacterBody2D)
├── Sprite2D
└── CollisionShape2D (CircleShape2D, radius: 17.0)
Ball Configuration
[ node name = "Ball" type = "CharacterBody2D" ]
script = ExtResource ( "1_wmsuy" ) # Attached ball.gd script
The ball uses a CharacterBody2D node type for physics-based movement with collision detection. The 17-pixel radius matches the ball sprite size.
Player Scene
File : res://scenes/player.tscn
The player scene represents the controllable paddle:
[ gd_scene load_steps = 4 format = 3 uid = "uid://bb2k1inx2tosy" ]
[ ext_resource type = "Texture2D" path = "res://sprites/Raquete.png" id = "1_1rmd5" ]
[ ext_resource type = "Script" path = "res://scripts/player.gd" id = "1_jpmcw" ]
Node Structure
Player (CharacterBody2D)
├── Sprite2D
└── CollisionShape2D (CapsuleShape2D, horizontal)
Player Configuration
[ node name = "Player" type = "CharacterBody2D" ]
script = ExtResource ( "1_jpmcw" ) # Attached player.gd script
speed = 730 # Exported property value
The collision shape is rotated 90 degrees (1.5708 radians) to create a horizontal paddle. Without this rotation, the capsule would be vertical.
Exported Properties
The player scene sets the speed property to 730 pixels per second, overriding the default value defined in player.gd.
Scene Instancing Pattern
Space Pong uses Godot’s instancing system to reuse scenes:
Define Prefabs
Ball and player are defined as standalone scenes with their own scripts and collision shapes.
Instance in Main Scene
The game scene instances these prefabs using instance=ExtResource() syntax.
Override Properties
Instanced scenes can have properties overridden (like the player’s speed = 730).
Maintain References
Scripts can reference other nodes using get_parent().get_node() to access the scene tree.
Resource UIDs
Godot 4.3 uses unique identifiers for scenes and resources:
# Scene UIDs
uid : // cc4souncpsicv # game.tscn
uid : // bh8d61b0k4152 # ball.tscn
uid : // bb2k1inx2tosy # player.tscn
# Texture UIDs
uid : // dbo6mpaatmx00 # Fundo6.png
uid : // qdy77c4bp2c # Bola.png
uid : // 7 lwxfgr 53 fj 7 # Raquete.png
UIDs ensure stable references even if files are moved or renamed. Godot automatically updates these references.
Collision Layers
The game uses Godot’s physics layers for collision detection:
CharacterBody2D nodes (ball, player) can collide with StaticBody2D walls
Area2D node (hole) detects overlaps with the ball
The ball uses move_and_collide() for physics-based bouncing
The player uses move_and_collide() for boundary-aware movement
Next Steps
Scripts Learn how the ball and player scripts control these scenes
Project Structure Understand the overall file organization