10.03.2015, 14:36
For future reference, there is a way without collection of iterators:
pawn Код:
new
Matrix[X_SIZE][Y_SIZE],
Iterator:Matrix<X_SIZE * Y_SIZE>
;
public OnGameModeInit()
{
//Example cells:
for(new x = 0; x != 3; ++x) {
for(new y = 0; y != 3; ++y) {
Matrix[x][y] = x * y;
Iter_Add(Matrix, x * Y_SIZE + y);
}
}
//Retrieving random cell:
new
rnd = Iter_Random(Matrix),
x = rnd / Y_SIZE,
y = rnd % Y_SIZE
;
printf("Cell at (%d, %d) value is equal %d", x, y, Matrix[x][y]);
return 1;
}