Treasure Hunter

I have question regarding loops, in this game, we are required to make a for loop like below:

for (let x = 46 ; x < 437 ; x += 78)

My question is, how does the code know the x variable is referring to coordinate? How does it automatically assume it is a coordinate?

Hi… because you send the value x and y in “add.sprite()” so if you check how add.sprite works , it accepts coordinates and the image.

1 Like

So basically we have already establish that x and y are coordinates because of the “add.sprite()” ?

Yes, those are the parametes add.sprite takes