I pass this part(04) but i don't understand why we need to write in createObject() : gameField[x][y] = new GameObject(y, x);
Why not (x, y)??? Why we not pass first the row(x) and second, the column(y)? Tk you!
Ps: i ask this question because i failed many times with =new GameObject(x, y);
for part.04!
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
21 September 2021, 19:42
you are confusing array indices with x/y coordinates. Take this array of int arrays as an example:
Lets say you want to get the number 1, which is in the top right corner. To access it you have to specify that you want the sub array at index zero and then the number at index three. So to get the number 1 you would use temp[0][3].
Now, if this were a grid with X,Y coordinates instead of an array the number 1 would be three along the X vertex and zero along the Y vertex. So you would say that it was at (3, 0). However, if you tried temp[3][0] you would get the number 2, which is in the bottom left corner. You can easily see this by using the int[][] example with these two output lines:
Remember: Arrays are not grids with x,y coordinates. They are two different concepts. This task has you using an array for the values, but the methods accept data in the format of X/Y coordinates. You will need to ensure that you correctly access the array. +1