Count down Timer not working?
              in 
             Programming Questions 
              •  
              7 months ago    
            
 
           
             Here is my code . Can some one please help? I don't know why my while loop will not execute properly?
            
             
            
            
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
               
             
             
               
             
             
              
             
             
              
             
             
              
             
             
              
             
             
                   
             
             
              
             
             
              
             
             
              
             
             
                    
             
             
                    
             
             
                      
             
             
                      
             
             
                        
             
             
                           
             
             
                          
             
             
                
             
             
              
             
             
              
             
             
                
             
             
              
             
             
           
 
            
           
              /**
             
             
               * PhotoBoothV2.pde
             
             
               */
             
             
              import processing.video.*;
             
             
              boolean sketchFullScreen() {
             
             
                return true;}
             
             
              // resolution: 800x600 - change it if you want
             
             
              //Crap
             
             
              //int cols = 320;
             
             
              //int rows = 240  ; 
             
             
              //720p
             
             
              //int cols = 1280;
             
             
              //int rows = 720 ; 
             
             
              //1080p
             
             
              int cols = 1920;
             
             
              int rows =1080; 
             
             
              Capture cam;
             
             
              int mainwidth  = cols;
             
             
              int mainheight = rows;
             
             
              PImage img1;
             
             
              PImage img2;
             
             
              PImage img3;
             
             
              PImage img4;
             
             
              int time5 = 20;
             
             
              int time4 = 30;
             
             
              int time3 = 40;
             
             
              int time2 = 50;
             
             
              int time1 = 60;
             
             
              int x ;
             
             
              PFont font;
             
             
              String number;
             
             
              long starttime;
             
             
              long time;
             
             
              //PImage img2;
             
             
              void setup() {
             
             
                size(1600,900);
             
             
                frameRate(30);
             
             
                //size(mainwidth, mainheight, JAVA2D);
             
             
                //size(1600,900);
             
             
               colorMode(RGB);
             
             
                cam = new Capture(this, cols, rows);
             
             
                cam.start();
             
             
                noSmooth();
             
             
               background(51);
             
             
              font = loadFont("AgencyFB-Bold-200.vlw");
             
             
              textFont(font);
             
             
               number = " ";
             
             
              }
             
             
              void draw() {
             
             
                if (cam.available()) {
             
             
                   cam.read();
             
             
                   image(cam, 0, 0,320,240);
             
             
                   fill(RGB);
             
             
                   fill(255,0,0);
             
             
                   text(number,100,100);
             
             
               }
             
             
              } 
             
             
              void keyPressed() {
             
             
               if (key == ' ') {  // space bar
             
             
               textSize(200);
             
             
               starttime = millis();
             
             
               x = 0;
             
             
               while (x < 5)
             
             
                {
             
             
               time = millis();
             
             
                  print(starttime - time);
             
             
                  if((starttime - time) == time5)
             
             
                  {
             
             
                   number = "5"; 
             
             
                    } 
             
             
                   else if ((starttime - time) == time4)
             
             
                    {
             
             
                    number = "4";
             
             
                    println(starttime-time);
             
             
                    }
             
             
                      else if ((starttime - time) == time3)
             
             
                      {
             
             
                      number= "3";
             
             
                      }
             
             
                        else if ((starttime - time) == time2)
             
             
                        {
             
             
                        number = "2";
             
             
                        } 
             
             
                          else if((starttime - time) == time1)
             
             
                          { 
             
             
                          number = "1";
             
             
                           }
             
             
                            x++;
             
             
              }
             
             
              save("temp/temp1.jpg");
             
             
              cam.save("temp/temp1.jpg");
             
             
              //  img1 =img.get();
             
             
               // img1.save("picture-####.jpg");
             
             
              // PImage img2 = createImage(320,240,RGB);
             
             
               //img2.loadPixels();
             
             
               //cam.stop();
             
             
               //saveFrame("picture-####.jpg");
             
             
               }
             
             
              if (key == 'l') {
             
             
               //cam.stop(); 
             
             
              img1 = loadImage("temp/temp1.jpg");
             
             
              image(img1, 0,0 );
             
             
              //image(img1, 0, 0);
             
             
              //image(img2, 0, 0);
             
             
              } 
             
             
                if (key == 'q'){
             
             
                    exit();
             
             
                  }
             
             
               }   
             
              
              
              1  
            
 
            
 
 
          