Going into this, I had the idea of making a top-down, action RPG game using the Godot engine. When the theme, "Free", was announced, I decided to amend this to a top-down stealth game where the player is either breaking free from some facility, or breaking in to a facility to rescue someone or something.
So day one I got to work creating a player scene, enemy scene, and wall scene based on what little I remembered from watching tutorials a while back. We also got some basic movement going for the player sprite:
Enemy detection of players will obviously be important, so I started working on that day two. I re-watched this video from the KidsCanCode channel on YouTube and attempted to duplicate some of that functionality. I didn't implement this using Area2d though, as they did in the tutorial, because 1) facing and fov will be an important factor of this game and 2) I really still don't get signals in Godot yet. I only have about 7-8 months of self-taught python programming under my belt, so working directly with GDscript makes more sense to me right now than using some of the other built in functionality of the Godot Engine. Anyway, first pass I came up with this using _draw() to display the enemy's field of view, and some boolean functions to change the color if the player scene is within the enemy's fov:
Which ALMOST works as intended. As you can see, the enemy thinks it can still "see" the player if the player exits the fov to the right. Following my understanding of the vector math tutorials from Godot's documentation, I was calculating the angle from two vectors--the facing vector (green line) and the vector from enemy-to-player--and checking if that result was less than half the value of my fov. It took an embarrassingly long amount of time to realize that the problem here was negative values for that angle will ALWAYS be evaluate as less than. Abs() function to the rescue, and:
Now I have the functionality I was looking for.
The next step will be to continue implementing the ideas of the video tutorial so that walls and other obstacles block vision. I'd like it to also change the way the cone is drawn so we can clearly see what will and won't be detected. Besides using this for debugging, I have an idea that it would be cool if the player could find power-ups or gear they could use to temporarily see the fov of enemy guards and scanners.
So that's what I'll be working on over the next few days (as well as possibly making some placeholder art that isn't just Godot logo recolored!)