|
Author |
Topic: falling objects (Read 268 times) |
|
nyubee
|
falling objects
« on: Nov 1st, 2003, 4:05am » |
|
int xs[100]; int ys[100]; for (int i=0; i<100; i++) { xs[i] = random(0,200); ys[i] = random(0,200); } i am trying to use this part of my code to show the effect of snow falling but it keeps giving syntax errors. is there an easier way in processing to make a falling effect - continually (when it all gets to the bottom it restarts from the top)? thanks
|
|
|
|
vent
|
Re: falling objects
« Reply #1 on: Nov 1st, 2003, 6:53am » |
|
Your problem is that your array declaration syntax is slightly incorrect and random() returns a float value, not an integer. solution: // declaring array syntax int[] xs = new int[100]; int[] ys = new int[100]; for (int i=0; i<100; i++) { // random returns float value. You need // to convert to int values if you want // to store these values in an array of integers. xs[i] = (int)(random(0,200)); ys[i] = (int)(random(0,200)); }
|
http://www.shapevent.com/
|
|
|
|