Tile Raycast Native Extension

Raycasting in tiled worlds using the DDA algorithm. It is a very effective solution for tile-based worlds such as platformers or top-down games.

Use Cases(AI Generated)

Ray Casting in Games

2D Top-Down Roguelikes: Games like “The Binding of Isaac” and “Enter the Gungeon” use ray casting for line-of-sight calculations, bullet trajectory.
Wolfenstein 3D and similar pseudo-3D engines: The original Wolfenstein 3D used DDA-based ray casting to create a 3D-like environment from a 2D map.
Minecraft uses a variation for block targeting and lighting calculations.

Line-of-Sight Systems

Tactical games like “XCOM” and “Into the Breach” use DDA for determining visibility between units.
Stealth games for guard vision cones and detection systems.

Procedural Generation

Dungeon crawlers like “Rogue Legacy” use it for connecting rooms and ensuring paths are traversable.
Spelunky and similar games for procedural level interconnections.

Other Applications

Tower defense games for targeting and projectile calculations.
Strategy games for unit visibility and pathing calculations.
Battle royale games for circle/zone damage calculations across grid terrain.

23 Likes

Thanks for another awesome extension!
Ive downloaded the platformer example to give a try (and see how it works) but I can’t run it locally. Some problems with the native extension idk


it’s something with the raycast.cpp. I’m using the 1.3.7 editor

2 Likes

Ah! Ok. Fix is on the way.
It is related to missing header on Windows(and probably on Linux). Works fine on MacOS.

Edit: turns out I use abs for floats :stuck_out_tongue:

2 Likes

@Dat_Indie I pushed the fix. You should at least restart the Defold.
If same thing happens, please delete the “build” and “.internal” folders from project directory.

1 Like

And also there is a much more simple example on the base repo:

1 Like

It’s working, thank you!

2 Likes

I’m aware that this native extension hasn’t gotten much attention, but I don’t know why!! :stuck_out_tongue_winking_eye: It’s actually very useful.
So I decided to update the extension and prepare new examples to showcase its use cases (coming next week)

Vision cone:

Simple line of sight:

9 Likes

Updated the library with new examples

Release Notes

  • BREAKING: Module name has been changed to tile_raycast
  • Complete code refactoring
  • Performance improvements
  • New vision cone and line of sight examples
10 Likes