Hello,
I shared my work on Breadth-First Search before:
https://forum.gdevelop.io/t/my-first-game-progress-and-bfs-breadth-first-search/
Now I want to share my Targeting Range Indicator.
Into The Beach🏖️ is a working name because my tiles are inspired by Into the Breach - the name and the map will change later. The idea is to make a non-canon Fallout 2 dungeon crawler.
This is my first game, and I am learning by doing. As I mentioned in my first post, I struggled a lot because the pathfinding behavior was not working with my diamond isometric tiles, so I made a virtual grid. The only downside is that my player now “teleports” instead of “walking,” but I guess it’s fine for a turn-based game.
What I did since then: now there are already 3 player-controlled characters with individual stats and initiative-based turn order.
Then I started working on the Targeting Range Indicator and got stuck again - none of the ideas were working. I wanted walls to block my line of sight. It was working fine in 4 directions, for example, I set the gun range to 5, then I highlighted 5 tiles in each direction one by one, and if a tile is blocked, it stops expansion. But then I thought that only 4 directions for a game where most guns will be ranged is not enough.
Then I found Bresenham’s line algorithm:
https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
It was interesting but hard to apply in GD. However, I realized that instead of counting tiles, I could use a line, and the line worked well.
First, I created a line from the player to the mouse cursor, which highlights tiles and stops at blocked tiles:

GIF is lagging a bit but it is much faster and smoother in game.
I think it was pretty cool, but again I wanted full targeting range, so I decided to make 64 static lines in all directions. Basically, when I open a weapon, it creates 64 lines, and the lines highlight my field of view. Of course, the lines will be invisible later - this is just an example of how it works:

I think it works fine for a small grid. If the grid were bigger, there would need to be more than 64 lines because there would be gaps at longer distances. Loading time is faster than expected - it takes maybe 0.5 seconds to draw the field of view. Also, if you have any advice on how to improve performance, it would be highly appreciated, as I am new to GD. Now I just need to set distance of the tiles and limit gun range based on a weapon type.
Overall, I am happy with the result. Again, it’s not the best way to do it, but I am glad that GD is flexible enough for alternative solutions. Next step will be creating smart enemies, and maybe I will release a prototype on itch.io in a month or so.
All the best ![]()
