Incremetly speed millis()?

hello, im working on a small project thats due in 2 hours and im hard stuck, i need to find a way to speed my clock in the same time as i speed the background to give it a “fast travel trough time” look.

  • Is there a way to speed up the millis() function with the frameRate or something like that to make the clock start spinning faster and faster?

this is the code:

Clock c;

// Array of stars
Star[] stars = new Star[400];
float f = 15;
float a = 90;

void setup() {
  size(800, 800);
  smooth();
  
  c= new Clock();

  // Init all stars
  for (int i=0; i<stars.length; i++) 
    stars[i] = new Star();
}

void draw() {
  
  c.run();
  
  
  //background+trail effect
  fill(0, a);
  rect(0, 0, width, height);
  frameRate(f);

  // Draw all stars wrt center of screen
  translate(width/2, height/2);

  stroke(255);
  strokeWeight(random(0.3, 5));

  // Update and draw all stars
  for (int i=0; i<stars.length; i++) {
    stars[i].update();
    stars[i].draw();
  }
  
  if (a > 10){
    a-= 0.09;
  } else {
    a=10;
  }
  
  f+= 0.2;
}


class Star {
  // Star coordinates in 3D
  float x;
  float y;
  float z;

  Star() {
    x = random(-5000, 5000);
    y = random(-5000, 5000);
    z = random(0, 2000);
  }

  void update() {
    z-=7;        // Move star closer to viewport
    if (z <= 0.0) // Reset star if it passes viewport
      reset();
  }

  void reset() {
    // Reset star to a position far away
    x = random(-5000, 5000);
    y = random(-5000, 5000);
    z = 2000.0;
  }

  void draw() {
    // Project star only viewport
    float offsetX = 100.0*(x/z);
    float offsetY = 100.0*(y/z);
    float scaleZ = 0.0001*(2000.0-z);

    // Draw this star
    pushMatrix();
    translate(offsetX, offsetY);
    scale(scaleZ);
    ellipse(0, 0, 20, 20);
    popMatrix();
  }
}

class Clock {
  
  int cx, cy;
  float secondsR, minutesR, hoursR, clockDiam;
  float s, m, h;
  int mstime = millis();  
  int minutes, seconds, hours, days, years;
  
  Clock () {
    
    int radius = min(width, height) /2;
    secondsR = radius * 0.4;
    minutesR = radius * 0.25;
    hoursR = radius * 0.15;
    clockDiam = radius * 0.5;
    
    cx= width/2;
    cy= height/2;
    
  }
  
  
  
  void run() {
    
    display();
    timer();
    
  }
  
  
  void timer() {
    
    if ( millis() > mstime + 1000) {
      mstime= millis();
      seconds = seconds +1;
    }
    
    if (seconds > 59) {
      minutes++;
      seconds = 0;
    }
    
    if (minutes > 59) {
      hours++;
      minutes = 0;
    }
    
    if (hours > 23) {
      days++;
      hours = 0;
    }
    
    if (days > 356) {
      years++;
      days = 1;
    }

  }
  
  void display() {

    float s = map(seconds, 0, 60, 0, TWO_PI) - HALF_PI;
    float m = map(minutes + norm(seconds, 0, 60), 0, 60, 0, TWO_PI) - HALF_PI; 
    float h = map(hour() + norm(minutes, 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;
    
    // Draw the minute ticks
    strokeWeight(2);
    stroke(255, 90);
    beginShape(POINTS);
    for (int a = 0; a < 360; a+=6) {
      float angle = radians(a);
      float x = cx + cos(angle) * secondsR;
      float y = cy + sin(angle) * secondsR;
      vertex(x, y);
    }
    endShape();
  
    stroke(255,0,0, 30);
    strokeWeight(2);
    line(cx, cy, cx + cos(s) * secondsR, cy + sin(s) * secondsR);
    strokeWeight(5);
    line(cx, cy, cx + cos(m) * minutesR, cy + sin(m) * minutesR);
    strokeWeight(7);
    line(cx, cy, cx + cos(h) * hoursR, cy + sin(h) * hoursR);
    
    fill(255);
    textAlign(LEFT);
    textSize(30);
    
    text("Day " + days + " Year " + years , width/2-90, height/2+50);
  }
   
}

you compare with 1000

you can reduce the number to 0 using a variable mTime

    if ( millis() > mstime + mTime) {
      mstime= millis();
      seconds = seconds +1;
      mTime-=14;
      if (mTime<=0)
        mTime=0;
    }

that works,

but that won’t make it faster than say 1 minute per sec or so (in your virtual time)

so you have to fake it and let the clock run faster using angle or whatever

Chrisir