Question about loops
in
Programming Questions
•
27 days ago
Hi, I'm new to programming and just finished the chapter on loops.
I have a class assignment where I'm suppose to make a circular loop. I've done part 1 and 2 so far and need help on third part.
The top left line circle goes all the way across but i cant get the bottom left on to do the same. Anyone help? I want to know what i'm do wrong or if there's an easier way of doing this.
This is my code so far.
float line;
float angle;
float endAngle;
float distance;
float endDistance;
void setup(){
size(420,420);
smooth();
line= 100;
angle = 0;
endAngle = angle + PI/2;
distance = 0;
endDistance = 600;
}
void draw(){
if(distance < endDistance){
distance += line;
}else if(angle <= endAngle){
angle += 0.01;
}
line(0,0,0+cos(angle)*distance,0+sin(angle)*distance);
if(distance < endDistance){
distance += line;
}else if(angle <= endAngle){
angle += 0.05;
}
line(0,420,0+cos(angle)*distance,0+sin(angle)/distance);
}
1