0 votes

Hi! I have a game built with a rocketship you can control and gravity wells around planets that you can fall into. However, to make the planets' surface I've simply used a large, circular sprite. This is an issue because when I scale up the planet, the jagged pixels become easily visible. To avoid these I would need ridiculously large image files to maintain a smooth appearance, which isn't practical. The first thing that came to mind was to use vector art, but I haven't found a way I can use it in Godot. Another solution would be to have the game render the circle as I play, but I haven't found a way to do this either. Any help or suggestions are greatly appreciated! :)

in Engine by (67 points)

1 Answer

+1 vote
Best answer

You can certainly do custom drawing in Godot, which easily includes typical geometric shapes. However, I guess it depends what you want for the final look of your circle. Are you really just looking for a basic circle shape? The advantage you have with an image-based solution is you can provide any amount of detail in the fill of the circle.

If you elect to simply draw a circle, that's really all you'll get without additional work. See the docs here for custom drawing info and samples - including a draw_circle() function.

https://docs.godotengine.org/en/stable/tutorials/2d/custom_drawing_in_2d.html#an-example-drawing-circular-arcs

by (10,914 points)
selected by

Thank you for the speedy response! This worked perfectly. However, I noticed the draw function (and the CollisionShape node) produces a ~20-gon rather than a circle, which is causing things to fall over. It's the same issue I had when I originally wanted to have a square world but failed to think of the reason real planets are spheres. Do you know if there is a solution to this at all or should I scale down the planets until it is unnoticeable? Take note that I am very new to game development and that all of this is certainly possible, I'm just wondering if it is in the realm of possibility for someone with my skill level and availability of spare time :p

You could certainly just draw the circle yourself, out of a sufficient number of lines to be smooth enough based on your requirements. Here's a thread containing a custom circle drawing method that's driven by a tolerance value.

https://godotengine.org/qa/40589/smooth-circle-with-draw_circle

Using something like that you should be able to create a relatively smooth circle, at the cost of it being made up of more segments...

Exactly what I needed! Thanks for steering me in the right direction :)

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 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 webmaster@godotengine.org with your username.