This is of course the best reassurance.
So there are of course still quite some bits that need improvement.
Even though rad_to_deg(..) returns seemingly whole numbers, it in fact does not. Same goes for floor(..).
They return float, which still makes exact matching with == unreliable. Reliable approximate comparisons between floats can be done with the is_equal_approx(..)
The other thing I noticed is that by using floor the angle representing the up direction becomes =~ -91.0 which is a little counter intuitive.
Then comes your wish to do the diagonal directions as well, which will come in multiples of - roundabout - 45.0
One more issue is that your angle may end up outside the ranges you test for entirely, a regular circle is often expressed between 0.0 and 360.0 decimal degrees. This means you need to somehow normalize your number to be in a predictable range:
So I’m sure there is a game dev best practice for what you’re doing that you can find in a tutorial somewhere, but at the moment it seems you’re stuck with me
, so here’s what I would do.
Make a set of boolean tests (like you did) to see in which range your normalized angle falls:
Up: between 360.0−(45.0*0.5) and 45.0*0.5
Up/Right: between 45.0*0.5 and 45.0+(45.0*0.5)
.. etcetera ..
Now I would also assign these values to const’s to give them meaningful names and to prevent them from having to be calculated over and over (although that’s probably optimized low level so doesn’t really cost anything performance wise, but we shouldn’t assume that).
Then.. at some point I would look at all this code I made and conclude: this code would have looked so much simpler if I had just opted for the Input option. Then I would:
- stash this code in a stale git branch for another day (never throw away code)
- delete all the lines and rewrite it using a good old Input map

I actually did do all this while learning Godot myself. I have been starting over all my life.
I give answers on this forum, but I’m still corrected all the time by more senior developers.
So in short: keep doing what you’re doing, but I won’t be here forever, so hopefully someone else will take over or, better yet, point you to the best learning material.
I’m just here a lot now because I only have my phone, get bored quickly and have a addictive personality (currently temporarily to this forum).