Table of Contents
GDScript is the primary scripting language for the Godot Engine. It is a high-level, dynamically typed language that is very similar to Python. Its syntax is designed to be clean and easy to read, making it a great choice for both beginners and experienced developers.
Key FeaturesLink to heading
- Python-like Syntax: If you are familiar with Python, you will feel right at home with GDScript.
- Integrated with Godot: GDScript is deeply integrated with the Godot editor, providing a seamless development experience with features like code completion and built-in documentation.
- Designed for Games: GDScript is specifically designed for game development, with built-in types for vectors, colors, and other common game development data structures.
ExampleLink to heading
Here is a simple example of a GDScript file that makes a character jump:
extends KinematicBody2D
var velocity = Vector2.ZEROconst JUMP_FORCE = -400const GRAVITY = 1000
func _physics_process(delta): velocity.y += GRAVITY * delta
if Input.is_action_just_pressed("jump"): velocity.y = JUMP_FORCE
velocity = move_and_slide(velocity, Vector2.UP)
This script defines the behavior of a player character, including gravity and jumping. It’s a great example of how GDScript can be used to quickly prototype game mechanics.