Initialize TileNavigatedArray properly

main
Bryson Zimmerman 11 months ago
parent d2d6fc4dd4
commit d782297e27

@ -13,10 +13,11 @@ import kotlin.math.abs
object ArrayBackedPathfinder { object ArrayBackedPathfinder {
//TODO: Replace with array for coordinate lookups for speed, do it in a separate pathfinder class to demonstrate the difference //TODO: Replace with array for coordinate lookups for speed, do it in a separate pathfinder class to demonstrate the difference
val gVals = TileNavigatedArray<Int>() val gVals = TileNavigatedArray<Int>(World.sizeX, World.sizeY, false)
//work along the path, marking tiles with VISITED along the way //work along the path, marking tiles with VISITED along the way
//if marking with visited is too expensive, just make the path and finalize it //if marking with visited is too expensive, just make the path and finalize it
fun generatePath(start: Tile, end: Tile) { fun generatePath(start: Tile, end: Tile) {
if(!start.isInBounds() || !end.isInBounds()) { if(!start.isInBounds() || !end.isInBounds()) {
throw IndexOutOfBoundsException("Cannot generate a path to or from an out of bounds tile") throw IndexOutOfBoundsException("Cannot generate a path to or from an out of bounds tile")
} }
@ -54,6 +55,7 @@ object ArrayBackedPathfinder {
} while( current != end) } while( current != end)
//At this point, a path is found //At this point, a path is found
markPath(start, end)
println("Path found!") println("Path found!")
} }

Loading…
Cancel
Save