Creating a timer


#1

Hi Everyone!

I am trying to create a timer in Processing. I have some letter forms that are falling from the top of the screen. I want them to land and then draw an ellipse over them. This part works fine. Then I want to create a larger ellipse after 5 seconds have elapsed. This part doesn’t work. I’ve tried this:

void setup () {
float time;
float LandingTime = -1;
float interval = 3000;

void draw() {
  time=millis();

  void display() {

  if(detectLanding() && landed){
    landed = true;
    blendMode(BLEND);
    noStroke ();
    smooth();
    fill(181, 197, 250, 150); 
    ellipse (x,y,14,10);  // this part works great
    
 if (LandingTime == -1) {
    LandingTime = millis();
  }
    
 else if (time - LandingTime > interval) {
    blendMode(BLEND);
    noStroke ();
    smooth();
    fill(181, 197, 250, 150); 
    ellipse (x, y, 30, 30);
    LandingTime = -1;
      }

Help! I feel like I’m really close but something is wrong with the order or syntax.

thanks,
alix


#2

Actually, the interval is 3 seconds in the code I pasted in…doesn’t matter…it’s not working.


#3

This isn’t directly related – it’s written for Arduino – but the code is almost exactly the same. Perhaps it would help:


#4

The helpful Processing Timer class might be useful as well!