This guide is deprecated since Godot 3.0's release. See the official GDScript style guide instead.
This is an unofficial style guide for Godot, a free, libre and open source game engine.
snake_case
is like_this.camelCase
is likeThis.PascalCase
is LikeThis.UPPER_SNAKE_CASE
is LIKE_THIS.
- Use
UPPER_SNAKE_CASE
for constants. - Use
snake_case
for variables and functions. - Use
snake_case
for input map names. - Use
snake_case
for all file names. - Use
PascalCase
for node names. - Use
PascalCase
for classes.
- Function arguments should have a space after each comma, like this:
func my_function(a, b, c):
pass
-
Begin comments with an uppercase letter, unless you are referencing a function or a variable. Do not end them with a period, unless the comment has several sentences.
-
Comments should have a space after the
#
symbol, and should be indented as usual.
Example:
# Outputs "Hello world!" to console
print("Hello world!")
- Always use tabs for indentation, GDScript does not like spaces anyway.
- Try to keep lines under 80 characters. Disregarding this guideline at times is acceptable, but over 100 characters is definitely too much.
- Put spaces around operators. Example:
print(str(5 * 40 + 2))
- In most cases, you should use
.tscn
scenes and.tres
resources as those are more friendly towards version control systems.
Follow this page as for directory structure.
If using Git, you should use a .gitignore
file that ignores certain patterns
from being added to your Git repository. It should be placed at the root of the
game folder. Here's an example that will suit most Godot projects:
.import/
.fscache
*~
Contributions are welcome, feel free to discuss on the issues.
Copyright (c) 2015-2017 Hugo Locurcio and contributors
CC0 1.0 Universal, see LICENSE.md.