Ask a weak and weak question
For example, there are two columns of pictures, there are no three images of the same size, I would like to ask the second picture above the first-dimension index value and the second-dimensional index value is what?
Because the game code to see the following two ends of the code, a little unclear the basics of the array.
The index value of the first dimension of the object in the piece[][] array
private int Indexx;
The index value of the second dimension of the object in the piece[][] array
private int indexy;
Reply to discussion (solution)
0 and 1 chant ...
You're not looking at PHP code.
Piece.setbeginx (Piece.getindexx () * imagewidth
+ Config.getbeginimagex ());
Piece.setbeginy (Piece.getindexy () * ImageHeight
+ Config.getbeginimagey ());
For example, the two-column chart starts with coordinates (0,0) and each image is 5 longer than the width.
The x-coordinate and y-coordinate of the second picture listed above in the above code are calculated as 0 and 15.
But the results should be 5 and 10.
No context, no explanation
Very faint.
1. Do you say the row or the column ah? From what you say "up and down" feeling is said to be OK, but the coordinates behind it are like columns of vertical rows
2. Subscript general habit starting from 0, that is (this is the serial number, and the following coordinates are different, distinguish)
(0,0) (0,1) ...
(1,0) (...)
The above is a one-dimensional row, two-dimensional is a column, if the one-dimensional is a column, two-dimensional is a row, then the position map becomes
(0,0) (1,0) ...
(0,1) (...)
A few people like to start from 1, to see the program
If the upper-left corner is [0,0] coordinates, then you say [5,10] is (2,1) the position of the upper left corner, [0,15] in the position of (3,0)?? This is used to indicate the position of the antecedent column.
Sorry, it is the next two lines, each line has three identical pictures, each picture length and width are 5
Now that the two-dimensional array is positioned on the coordinate, the first picture on the line clings to the X-and y-coordinates (the coordinates of the lower-left corner of the picture are (0,0))
My question: What is the first and second-dimensional index values of the second picture object in the upstream?
Because the following look at the index value of the second bit of the image object in the array, this is not very clear.
The index value of the first dimension of the object in the piece[][] array
private int Indexx;
The index value of the second dimension of the object in the piece[][] array
private int indexy;
When organized by [Y][x]
[0] [0] [0][1] [0][2]
[1] [0] [1][1] [about]
When organized by [X][y]
[0] [0] [1][0] [2][0]
[1] [0] [1][1] [2][1]
As you can see, the origin is placed in the upper-left corner of the array. Therefore, the image should also be placed in the upper left corner, so that analysis, calculation is convenient
If you place the original point of the picture in the lower-left corner, there is y ' = h-y
That is, the coordinate system has a vertical flip
What is the first and second-dimensional index values for the second picture object in the upstream?
Is it 0 and 1?
0 rows, 1 columns.
It's 0 1.
When organized by [Y][x]
[0] [0] [0][1] [0][2]
[1] [0] [1][1] [about]
When organized by [X][y]
[0] [0] [1][0] [2][0]
[1] [0] [1][1] [2][1]
The upper part is not very clear.
Is it organized by [y][x] or by [X][y]?
How the data is organized is based on your needs
You can x, y (column, row)
You can also y,x (row, column)
This question hasn't been clarified yet? Thought Lao Xu could make you understand.
Coordinates are fixed x, y
But the array subscript is determined by the person who wrote the program, either M,n or N,m (m for row, N for column)
The minimum value of M or n (that is, the subscript of the first row/column) is the person who writes the program himself, and when he walks, he takes care to start with the minimum value.
If the one-dimensional is a column and the two-dimensional is a row, the position map becomes
(0,0) (1,0) ...
(0,1) (...)
When organized by [X][y]
[0] [0] [1][0] [2][0]
[1] [0] [1][1] [2][1]
Why is one dimension a column and two-dimensional rows so sorted?
According to the common sense is not one-dimensional is the row, two-dimensional is the column?
According to the coordinates of the mathematical description
X Horizontal axis
Y Vertical Axis
Sit punctuation = (x, y)
This is common sense!