GDScript is a high-level, dynamically typed scripting language. It is the primary language designed specifically to be used for developing games and interactive applications within Godot.
GDScript features a syntax similar to Python, making it relatively easy for developers familiar with Python or similar languages to pick up. It is designed to be concise and readable, with a focus on simplicity and efficiency.

1 # Member variables.
2 var a = 5
3 var s = "Hello"
4 var arr = [1, 2, 3]
5 var dict = {"key": "value", 2: 3}
6 var other_dict = {key = "value", other_key = 2}
7 var typed_var: int
8 var inferred_type := "String"
9
10 # Constants.
11 const ANSWER = 42
12 const THE_NAME = "Charly"
13
14 # Enums.
15 enum {UNIT_NEUTRAL, UNIT_ENEMY, UNIT_ALLY}
16 enum Named {THING_1, THING_2, ANOTHER_THING = -1}
17
18 # Built-in vector types.
19 var v2 = Vector2(1, 2)
20 var v3 = Vector3(1, 2, 3)
21
22 # Functions.
23 func some_function(param1, param2, param3):
24 const local_const = 5
25
26 if param1 < local_const:
27 print(param1)
28 elif param2 > 5:
29 print(param2)
30 else:
31 print("Fail!")
32
33 # Constructor
34 func _init():
35 print("Constructed!")
36 var lv = Something.new()
37 print(lv.a)
1 # Python program to implement Atbash Cipher
2
3 # This script uses dictionaries to lookup various alphabets
4 lookup_table = {
5 'A' : 'Z', 'B' : 'Y', 'C' : 'X', 'D' : 'W', 'E' : 'V',
6 'F' : 'U', 'G' : 'T', 'H' : 'S', 'I' : 'R', 'J' : 'Q',
7 'K' : 'P', 'L' : 'O', 'M' : 'N', 'N' : 'M', 'O' : 'L',
8 'P' : 'K', 'Q' : 'J', 'R' : 'I', 'S' : 'H', 'T' : 'G',
9 'U' : 'F', 'V' : 'E', 'W' : 'D', 'X' : 'C', 'Y' : 'B', 'Z' : 'A'}
10
11 def atbash(message):
12 cipher = ''
13 for letter in message:
14 # checks for space
15 if(letter != ' '):
16 #adds the corresponding letter from the lookup_table
17 cipher += lookup_table[letter]
18 else:
19 # adds space
20 cipher += ' '
21
22 return cipher
23
24 # Driver function to run the program
25 def main():
26 #encrypt the given message
27 message = 'GEEKS FOR GEEKS'
28 print(atbash(message.upper()))
29
30 #decrypt the given message
31 message = 'TVVPH ULI TVVPH'
32 print(atbash(message.upper()))
33
34
35 # Executes the main function
36 if __name__ == '__main__':
37 main()
GDScript supports object-oriented programming (OOP) principles, including classes, inheritance, and polymorphism. It includes built-in data types such as integers, floats, strings, arrays, dictionaries, and more. It also provides extensive support for vectors, matrices, and mathematical operations commonly used in game development.
Overall, GDScript is a powerful and user-friendly programming language. It is both simple and flexible, and may be a good choice for new developers looking to create games.
Was this helpful?
1 / 0
Comment