-
Creating a random number grid that automatically positions x and position y.
Hi, I am trying to create a random number grid having the x position expressed by index*(pixel value that fills the grid horizontally). Then when the first column fills, the x position returns to 1st column but the y position goes down to a certain amount of pixels. I am able to get it to work for 2 columns and rows with a multi-condition statement, but I know that it could be written as an equation, but not sure how to do it in javascript. There’s always 19 columns before it should repeat so I’m guessing something to do with a variable representing multiples of 19 so that y position would drop down every 20, but at a loss beyond that. Appreciate any help with this. Thanks, David
x position code//
if (index<=19) {
index*192
} else if (index>19 || index<=38) {
(index-19)*192
} else if (index>38 || index<=57) {
(index-38)*192
} else if (index>57 || index<=76) {
(index-57)*192
} else if (index>76 || index<=95) {
(index-76)*192
} else if (index>95 || index<=114) {
(index-95)*192
}y position code//
if (index<=19) {
144
} else if (index>19 || index<=38) {
288
} else if (index>38 || index<=57) {
432
} else if (index>57 || index<=76) {
576
} else if (index>76 || index<=95) {
720
} else if (index>95 || index<=114) {
864
}random number code (which is working okay to generate a random number between 1 and 9//
seedRandom(1,true);
Math.round(random(1,9));