0 votes

I'm developing a toy game that imitate Zuma: https://github.com/FelicePollano/Soma.
The code I initially wrote was entirely contained in a scene, then I realized it was so generic that I can use in more than one level, so I moved to a class in a script and have the level scenes deriving from that class. Is this a good practice in Godot as well ( I come from object oriented design, so I'm a little biased )
Another question: I realized I can be further more generic by extracting the code driving the balls along the path to have more than one path per level, so I will have a third class containing the ball class engine that will be instantiated and parametrized in the code of the single level. Is this a good approach in Godot?
Thanks in advance.

Godot version 3.5
in Engine by (36 points)

1 Answer

+1 vote
Best answer

Gdscript can be viewed as object oriented so principles of object oriented programming apply here. It is even in the best practices guide. Generally, using inheritance to reduce code duplication is a good thing. Also giving each object its own script instead of having one script controlling everything is a good idea as it reduces code complexity. This is a good thing as it really helps with bug fixing and maintenance of your code.

This seams like the approach you are taking so I think it's fine.

by (1,987 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.