Hi folks,
So I’ve come to an issue which I can’t seem to think of a way through.
I don’t currently have any produced code, just thinking of it and procedural thoughts as text right now.
The goal: To have an object find it’s way to the exit by following a pre-defined array containing co-ordinates of each tile it must go to.
The issue: If I were to do the code below, it wouldn’t work since the Y value would always be greater than the objects current Y value.
// there would be an array that contains value such as [0][0] = start pos, [7][7] = end pos
// the first if statement would continuously be run and...
// the object would always move up and would never go right/left etc.
if (object.y < nextPoint[i][1]) {
// move up
}
if (object.x < nextPoint[i][0]) {
// move right
}