xyz
Which part?
I got the raycasting working, but I'm still not happy with the algorithm I'm using to decide which tiles to reveal.
The code that reveals the tiles is basically exactly what you wrote:
extends TileMapLayer
var invisibletiles: Array[Vector2i]
@onready var hero = $"../../Hero"
func reveal_tile(collisionpoint: Vector2):
var coords = self.local_to_map(collisionpoint)
var herocoords = self.local_to_map(hero.position)
var x_start = min(herocoords.x, coords.x)
var x_end = max(herocoords.x, coords.x)
var y_start = min(herocoords.y, coords.y)
var y_end = max(herocoords.y, coords.y)
for x in range(x_start,x_end + 1):
for y in range(y_start,y_end + 1):
if Vector2i(x,y) in invisibletiles:
invisibletiles.erase(Vector2i(x,y))
notify_runtime_tile_data_update()
func _ready():
pass
func _use_tile_data_runtime_update(coords):
if coords in invisibletiles: return true
else: return false
func _tile_data_runtime_update(coords, tile_data):
if coords in invisibletiles:
tile_data.modulate.a = 0