What is inputDir variable? (I didn’t write this code, I’m learning it from a tutorial, you know tutorials don’t cover stuffs well).
What I’m not understanding is why are we setting inputDir at 0th row, 1st column? What does that mean? Can you provide some explanations with figures(if possible) about this issue?
And neither did we, which brings about a small problem: Whose intellectual rights are we possibly trampling on, here?
Any one of us could run headlong into deciphering the code for you, yet to what end? I hate to leave this question unanswered, but I feel we are stepping on somebody’s toes in so doing. You will have to take it up with whomever you got this code from, and then maybe get back to us with what further ensues; do, please.
I must tell why my confusion came here:
Earlier in the code, we’ve done this:
//head of snake
let snakeArr = [
{
x: 13,
y: 15
}
]
Here x,y means the grid row 13, grid column 15. That is why I’m confused. We’re using same variable names in 2 places with different meanings. In this question, we’re using x,y for direction(up,down etc).
Still not sure about the question, but in objects it is normal to have keys in common, such as, x and y. They are encapsulated in their own space so do not conflict with each other, and they can have exclusive values. We can map any one of them to a global pair of x and y variables for one time use.