Hi, I’m still new to Godot, as I mostly use Pygame. I’ve become somewhat familiar with Godot and find it easy to use with its own Python-like programming language.
I already have basic setup how to convert pygame to gdscript.
Questions:
1. Any ideas what version to use? 2. Should i preload GDScript every time or only preload it once and assign to a variable? (Example 1) 3. Should i use Image, Sprite or Viewport as Surface like in Pygame? 4. Would anyone like to have functions like exec and eval based on loading external .gd files?
→ other ideas please comment
Examples:
1.
var pi_ = preload("res://math.gd").pi
var Vector2_ = preload("res://math.gd").Vector2
or
math_ = preload("res://math.gd")
var pi_ = math_.pi
var Vector2_ = math_.Vector2
During run-time, the resource is loaded when the script is being parsed. This function effectively acts as a reference to that resource.
The file will only be loaded once regardless of how many times you use preload. Whether or not you assign it to a variable is up to you. Do you want to type preload("res://math.gd") everywhere, or do you want to just type math_?
A lot of what you’re doing here seems to be replicating existing functionality in Godot. Which is fine if that’s what you want, but (for example) your Math.gd could just be brought in as a global file by adding it to the globals list in the project settings, and that will also get you Math.pi, though there’s also already a global constant PI, and a lot of the math functions are already included.