all GDScript documentation
- User
all GDScript documentation
Assistant
Here's an overview of GDScript based on the documentation and resources provided:
Key Features of GDScript
- High-level, object-oriented, imperative programming language built specifically for Godot
- Syntax similar to Python, using indentation for code blocks
- Gradually typed - can use dynamic or static typing
- Designed to be easy to learn and use, especially for game development in Godot
Basic Syntax
- Comments use # for single line, multiple # for multi-line
- Print output with print() function
- Indentation defines code blocks
- No semicolons needed at end of lines
- Case sensitive
Variables and Data Types
- Basic types: null, bool, int, float, String
- Can declare variables without specifying type:
var x = 5 var name = "Player" - Can use type hints:
var score: int = 0 var velocity: Vector2 = Vector2(0, 0) - Constants with const keyword:
const SPEED = 300
Functions
- Defined with func keyword:
func my_function(param1, param2): print(param1) return param2 - Can specify return type:
func calculate_damage() -> int: return base_damage * multiplier
Classes and Objects
- Scripts define classes
- Inheritance with extends keyword
- Constructor is _init() function
- Properties and methods defined in class body
Other Key Features
- Built-in vector types like Vector2, Vector3
- Enums
- Dictionaries and arrays
- Signals for communication between objects
- Export keyword to expose properties to editor
Best Practices
- Use PascalCase for class names, snake_case for functions/variables
- Document code with ## comments above functions/classes
- Follow official GDScript style guide
GDScript is designed to be approachable for beginners while still being powerful enough for complex game logic. Its tight integration with Godot makes it very efficient for game development workflows.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.