How to make perfectly smooth circles on a large scale?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By redstonecreeper8

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! :slight_smile:

:bust_in_silhouette: Reply From: jgodfrey

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.

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 :stuck_out_tongue:

redstonecreeper8 | 2020-11-20 22:52

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.

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…

jgodfrey | 2020-11-20 23:14

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

redstonecreeper8 | 2020-11-20 23:51