We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everybody,
i have a problem. I want to do less coding but im not sure how to declare about 2*1000 variables without writing each of them. I want to have a falling numbers display just like in the movie "Matrix". I have written parts of two of theses line. Here is my code.
My aim is to have falling number lines with different speed each, I have almost done the main programming, but my code declares every falling number and it would take a lot of time to write each down in the code. I was thinking of using a for-loop for declaring the variables but i'm not sure how to mange it exactly!
Thanks
// first line position variables
float a1;
float a2;
float a3;
float a4;
float a5;
float a6;
float a7;
float a8;
float a9;
float a10;
float a11;
// first line numbers between 0 and 1
int i1 = 1;
int i2 = 0;
int i3 = 1;
int i4 = 1;
int i5 = 0;
int i6 = 0;
int i7 = 0;
int i8 = 0;
int i9 = 1;
int i10 = 0;
int i11 = 0;
//second line position
float b1;
float b2;
//second line numbers between 0 and 1
int j1;
int j2;
void setup() {
size(displayWidth,displayHeight);
stroke(255);
a1 = 0;
a2 = -15;
a3 = -30;
a4 = -45;
a5 = -60;
a6 = -75;
a7 = -90;
a8 = -105;
a9 = -120;
a10 = -135;
a11 = -150;
b1 = 0;
b2 = -30;
}
void draw() {
background(0);
fill(#1DDE14);
textSize(15);
// first falling line
text(i1, 5, a1);
a1 = a1 + 2;
if (a1 > height) {
a1 = 0 ;
// makes different combinations of numbers appear after the falling line reach the ground
i1 = round(random(0,1));
}
text(i2, 5, a2);
a2 = a2 + 2;
if (a2 > height) {
a2 = 0 ;
i2 = round(random(0,1));
}
text(i3, 5, a3);
a3 = a3 + 2;
if (a3 > height) {
a3 = 0 ;
i3 = round(random(0,1));
}
text(i4, 5, a4);
a4 = a4 + 2;
if (a4 > height) {
a4 = 0 ;
i4 = round(random(0,1));
}
text(i5, 5, a5);
a5 = a5 + 2;
if (a5 > height) {
a5 = 0 ;
i5 = round(random(0,1));
}
text(i6, 5, a6);
a6 = a6 + 2;
if (a6 > height) {
a6 = 0 ;
i6 = round(random(0,1));
}
text(i7, 5, a7);
a7 = a7 + 2;
if (a7 > height) {
a7 = 0 ;
i7 = round(random(0,1));
}
text(i8, 5, a8);
a8 = a8 + 2;
if (a8 > height) {
a8 = 0 ;
i8 = round(random(0,1));
}
text(i9, 5, a9);
a9 = a9 + 2;
if (a9 > height) {
a9 = 0 ;
i9 = round(random(0,1));
}
text(i10, 5, a10);
a10 = a10 + 2;
if (a10 > height) {
a10 = 0 ;
i10 = round(random(0,1));
}
text(i11, 5, a11);
a11 = a11 + 2;
if (a11 > height) {
a11 = 0 ;
i11 = round(random(0,1));
}
//second falling line
text(j1, 300, b1);
b1 = b1 + 2;
if (b1 > height) {
b1 = 0 ;
j1 = round(random(0,1));
} text(j2, 300, b2);
b2 = b2 + 2;
if (b2 > height) {
b2 = 0 ;
j2 = round(random(0,1));
}
}
Answers
You should seriously consider taking a look at array's reference: http://processing.org/reference/Array.html o->
Here's some "The Matrix" example from the old forum: <):)
Hey buddy,
Ok, I will. I had that kind of idea, but i was not really sure about it. I'll try to figure out.
Thanks
see this one also:
http://archive-org.com/page/4420950/2014-08-17/http://wiki.processing.org/index.php?title=From_several_variables_to_arrays&printable=yes
As if it was written for me. Thanks