0% found this document useful (0 votes)
102 views3 pages

Gdscript Cheat Sheet

This GDScript cheat sheet provides an overview of basic syntax, including variables, functions, comments, conditionals, and loops. It outlines data types such as integers, floats, booleans, strings, arrays, and dictionaries, as well as object-oriented programming concepts like classes and inheritance. Additionally, it covers signals and events, built-in nodes, and functions for scene management and movement.

Uploaded by

christianmuwa42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views3 pages

Gdscript Cheat Sheet

This GDScript cheat sheet provides an overview of basic syntax, including variables, functions, comments, conditionals, and loops. It outlines data types such as integers, floats, booleans, strings, arrays, and dictionaries, as well as object-oriented programming concepts like classes and inheritance. Additionally, it covers signals and events, built-in nodes, and functions for scene management and movement.

Uploaded by

christianmuwa42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

GDScript Cheat Sheet

Basic Syntax:

- Variables: var name = value

- Functions: func function_name():

- Body of the function

- Comments: # This is a comment

- Conditionals:

if condition:

# Code block

elif another_condition:

# Code block

else:

# Code block

- Loops:

for i in range(10):

# Code block

while condition:

# Code block

Data Types:

- int: Integer numbers (e.g., var x = 5)

- float: Floating-point numbers (e.g., var x = 5.5)

- bool: Boolean values (e.g., var is_true = true)

- String: Text values (e.g., var text = "Hello")

- Array: List of elements (e.g., var arr = [1, 2, 3])


- Dictionary: Key-value pairs (e.g., var dict = {"key": "value"})

Functions and Methods:

- Defining a function: func function_name():

- Code block

- Returning values: return value

- Built-in functions:

- print(value): Print to the console

- len(array): Get length of an array

- str(variable): Convert to string

Object-Oriented Programming:

- Classes: class ClassName:

- Constructor: func _init():

- Initialize variables

- Accessing members: object.member

- Inheritance: class Child extends Parent:

Signals and Events:

- Defining signals: signal signal_name

- Emitting signals: emit_signal("signal_name")

- Connecting signals: connect("signal_name", object, "method_name")

Built-in Nodes and Functions:

- Scene nodes: Node, Sprite, Camera2D, Area2D, etc.

- Accessing nodes: var node = get_node("path/to/node")

- Positioning: position, scale, rotation


- Movement: move_and_slide(), move_local_x(), etc.

You might also like