How to limit random to integers?
in
Programming Questions
•
11 months ago
I'm trying to make 20 balls colliding with vector but it gives me a message like: cannot convert float to int
So I thought limiting the random to integers it would work.
Please help me guys o/
int[] x;
int[] y;
int[] vx;
int[] vy;
int i;
void setup () {
size(600,600);
background(0);
x = new int [20];
y = new int [20];
vx = new int [20];
vy = new int [20];
for (i = 0; i < 20; i++) {
x[i] = random(width); //it marks this point
y[i] = random(height);
vx[i] = random(width);
vy[i] = random(height);
}
}
1