# Having trouble with code

I’m having trouble figuring out why line 19 (t+=0.5;) is unreachable. Can somebody have a look, please?

``````
static final int NUM_LINES = 10;

float t;

void setup() {
background(20);
size(500,500);
}

void draw() {
background(20);
stroke(255);
strokeWeight(5);
translate(width/2, height/2);
for (int i = 0; 1 < NUM_LINES; i++) {
line(x1(t+i),y1(t+i),x2(t+i),y2(t+i));
}
t+=0.5;
}

float x1(float t){
return sin(t/10) * 100 + sin(t/5) * 20;
}

float y1(float t){
return cos(t/10) * 100;
}

float x2(float t){
return sin(t/10) * 100 + sin(t) * 2;
}

float y2(float t){
return cos(t/20) * 200 + cos(t/12) * 20;
}
``````

First, your for loop is wacky. You want to be checking the value of i, but instead you’ve accidentally put 1

Change
for (int i = 0; 1 < NUM_LINES; i++)
to
for (int i = 0; i < NUM_LINES; i++)

But that shouldn’t keep you from getting to the next line, it should just prevent the loop from running.

But that next line adds 0.5 to t. What does t equal before this? You never initialize it.

2 Likes

Hello, @Lolman223, and welcome to the Processing Foundation Forums!

You have this:

``````  for (int i = 0; 1 < NUM_LINES; i++) {
``````

Due to the condition, `1 < NUM_LINES`, it is an infinite loop.

1 Like

Thank you so much for your help

1 Like

DOH! I got my < and > mixed up

Hello, @richhelvey and welcome to the Processing Foundation Forums!

Yeah, with the condition corrected based on your observation, and with a proper initialization of `t`, the program will run, with all lines of code reachable, and with a nice animation to display.