Thanks for the hint, I always get confused wuth this looping
Here's a my disastrous sketch, eventually it will be followed bu a text explaining what it's all about, but right now it;s just a sequence of different things:
PFont font;
Stars[] stars;
int i, k;
float x, h, n = 2,m;
float y;
float ySpeed = .98;
float xSpeed = 1.005;
float j;
float speedX, speedY;
float adjustl;
float accelerationX = .04, accelerationY = .05;
boolean step1 = false;
boolean step2 = false;
boolean step3 = false;
boolean step4 = false;
boolean step5 = false;
//sin parameters
float px, py;
float angle;
float radius = 50;
float frequency = 2;
void setup(){
size(500, 300);
background(0);
frameRate(30);
x = width/2;
y = height/2;
smooth();
font = loadFont("Arial-Black-16.vlw");
stars = new Stars[3];
}
void draw(){
if (i<=width/2+5){
move(100, 0, 0, width/2, height/2, width, height/2, "X", width-20, height/2-5,
width-10, height/2-5, width-10, height/2+5, width, height/2,
i+250, height/2);
speedX += accelerationX;
i+=speedX;
}
else {
step1 = true;
}
if(step1)
{
if (j<height){
move(0, 100, 0, width/2, height/2, 0, height,
"Y", 1, height-10,1, height-1, 10, height-10, 20, height-10, height-j,350-2*(height-j)/3);
speedY += accelerationY;
j+=speedY;
}
else {
step2 = true;
}
}
if(step2)
{
if (x>=width/2&&x<width) {
move(0, 0, 100, width/2, height/2, width/2, 0,
"Z", width/2-20, 20, width/2, 1, width/2-5, 5, width/2+5, 5, x, y);
x *= xSpeed;
ySpeed += accelerationY;
y -= ySpeed;
}
else {
step3 = true;
}
}
if (step3){
drawClock();
m++;
if(m==200){
background(0);
step4 = true;
}
}
if (step4){
for (int s = width/8; s < width; s++){
for(int t = height/4; t < height; t++){
for (int p = 0; p< stars.length;p++){stars[p] = new Stars(color(random(0,255), random(0,255), random(0,255)), 2, 4, 2, s, t, true);
stars[p].display();}
}
}
}
}I suppose the problem is somewhere here, I need to show the clock for some time, hide it and draw a few random glowing points. But right now it just hangs after showing the clock.
void move(int ellipsecolor1, int ellipsecolor2, int ellipsecolor3, int x1_line, int x2_line, int y1_line,
int y2_line, String name, int textpos_x, int textpos_y, int x1_triangle, int y1_triagle, int x2_triangle, int y2_triangle, int x3_triangle, int y3_triangle, float x_ellipse, float y_ellipse)
{
fill(0, 50);
rect(0,0, width, height);
stroke(ellipsecolor1, ellipsecolor2, ellipsecolor3, 50);
strokeWeight(2);
line(x1_line, x2_line, y1_line, y2_line);
fill(ellipsecolor1, ellipsecolor2, ellipsecolor3);
textFont(font);
text(name, textpos_x, textpos_y);
triangle(x1_triangle, y1_triagle, x2_triangle, y2_triangle, x3_triangle, y3_triangle);
stroke(ellipsecolor1, ellipsecolor2, ellipsecolor3);
ellipse(x_ellipse, y_ellipse, 10, 10);
}
void drawStaticSin(float n){
// draw static curve - y = sin(x)
for (int i = 0; i< width; i++){
py = sin(radians(angle))*(n*radius);
stroke(255, 80);
point(i, py);
angle -= frequency;
}
}
void drawClock(){
background(0);
noFill();
noStroke();
// Angles for sin() and cos() start at 3 o'clock;
// subtract HALF_PI to make them start at the top
ellipse(3*width/4, height/4, 20, 20);
float s = map(second(), 0, 60, 0, TWO_PI);
float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI);
float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2);
stroke(255);
strokeWeight(1);
line(100, 100, cos(s) * 72 + 100, sin(s) * 72 + 100);
strokeWeight(2);
line(100, 100, cos(m) * 60 + 100, sin(m) * 60 + 100);
strokeWeight(4);
line(100, 100, cos(h) * 50 + 100, sin(h) * 50 + 100);
// Draw the minute ticks
strokeWeight(2);
for (int a = 0; a < 360; a+=6) {
float x = 100 + ( cos(radians(a)) * 72 );
float y = 100 + ( sin(radians(a)) * 72 );
point(x, y);
}
}
class Stars {
color c;
float rMin;
float rMax;
float r;
float Xpos;
float Ypos;
boolean grow;
// The Constructor
Stars(color tempC, float tempRMin, float tempRMax, float tempR, float tempXpos, float tempYpos, boolean tempGrow) {
c = tempC;
rMin = tempRMin;
rMax = tempRMax;
r = tempR;
Xpos = tempXpos;
Ypos = tempYpos;
grow = tempGrow;
}
void display() {
background(0);
stroke(c);
fill(c);
r = rMin;
ellipse(Xpos, Ypos, r, r);
noFill();
for (int i = 1; i < 20; i++)
{
stroke(red(c), green(c), blue(c), 255/i);
strokeWeight(2);
ellipse(Xpos, Ypos, r+i, r+i);
}
if ( grow )
{
r += 8/frameRate;
if ( r > rMax ) grow = false;
}
else
{
r -= 8/frameRate;
if ( r < rMin ) grow = true;
}
}
}