Is there anyway to countdown or countup some range of numbers? (it has to be visible)

edited May 2014 in How To...

I want to make it visible at the stage counting up the some arrays...

I mean..for example

int[] array = {1245, 1260, 1280}

then I want to show 1245,1246,1247 ....1260 not just 1245, 1260, 1280...

Someone plz help me ; (

Answers

  • edited May 2014

    use for-loop to loop over the array (up to length-1)

    use then 2 vars and read the value of the array in the 1st var currentValue

    use while() to loop until the value of the array (index+1) is reached

    use text() to show the number currentValue

    increase currentValue

    then while loop is quit, for-loop continues

  • here

    int[] array = {
      1245, 1260, 1280
    };
    IntList inventory;
    int i = 0; 
    
    void setup () {
      background(0);
      frameRate(2);
      inventory = new IntList();
      inventory.set(0, array[0]);
      for (int i = 0; i < array.length-1; i++) {
        for (int j = array[i]; j < array[i+1]; j++) {
          inventory.append(j);
        } // for
      } // for
      inventory.append(array[array.length-1]);
    } // func 
    
    void draw() {
      background(0);
      text ( inventory.get(i), 30, 39);
      if (i<inventory.size()-1)
        i++;
    } // func 
    //
    
  • this was more difficult than expected and I had to change the initial idea...

    ;-)

Sign In or Register to comment.