Stuck
              in 
             Programming Questions 
              •  
              2 years ago    
            
 
           
             I'm a grad student in painting, learning processing language for the first time.  I've gotten nearly half way through Shiffman's Learning Processing textbook but stuck on one of the lessons in the book.  Could anyone please take a second to look at this code and let me know what you think might be wrong?
            
             
            
            
             
              
             
             
              
             
             
              
             
             
                
             
             
                
             
             
                   
             
             
                 
             
             
                
             
             
                 
             
             
              
             
             
                  
             
             
                
             
             
           
 
            
           
              Zoog[] zoogies = new Zoog[200];
             
             
              void setup() {
             
             
                size(500,500);
             
             
                smooth();
             
             
                frameRate(60);
             
             
                for (int i = 0; i < zoogies.length; i++) {
             
             
                  zoogies[i] = new Zoog(color(80,225,180),250,200,60,60,16,random(255),random(255),random(255),random(255));
             
             
                }
             
             
              }
             
             
              void draw() {
             
             
                background(65); //draw a light grey background
             
             
                // operate Zoog object;
             
             
                for (int i = 0; i < zoogies.length; i++) {
             
             
                  zoogies[i].display();
             
             
                  zoogies[i].jiggle();
             
             
                }
             
             
              }
             
             
              class Zoog {
             
             
                // Zoog's variables
             
             
                color c; 
             
             
                float x; 
             
             
                float y; 
             
             
                float w; 
             
             
                float h; 
             
             
                float eyeSize;  
             
             
                float eyeR; 
             
             
                float eyeG; 
             
             
                float eyeB; 
             
             
                float eyeA;
             
             
                // Zoog constructor
             
             
                Zoog(color tempC, float tempX, float tempY, float tempW, float tempH, float tempEyeSize, float tempEyeR, float TempeyeG, float tempEyeB, float tempEyeA) {
             
             
                  c = tempC;
             
             
                  x = tempX; 
             
             
                  y = tempY; 
             
             
                  w = tempW; 
             
             
                  h = tempH; 
             
             
                  eyeSize = tempEyeSize; 
             
             
                  eyeR = tempEyeR; 
             
             
                  eyeG = tempEyeG; 
             
             
                  eyeB = tempEyeB;
             
             
                  eyeA = tempEyeA;
             
             
                }
             
             
                 // Move Zoog 
             
             
                 void jiggle (float speed) {
             
             
                   //change the location
             
             
                   x = x + random(-1,1)*speed;
             
             
                   y = y + random(-1,1)*speed;
             
             
                 }
             
             
                 // Constrain Zoog to window
             
             
                 float x = constrain(x,0,width);
             
             
                 float y = constrain(y,0,height);
             
             
              }
             
             
                 // Display Zoog
             
             
                void display() {
             
             
                  // set ellipses and rects to CENTER mode
             
             
                  ellipseMode(CENTER);
             
             
                  rectMode(CENTER);
             
             
                  // set color & stroke
             
             
                  fill(c);
             
             
                  stroke(0);
             
             
                  //body
             
             
                  rect(x,y,w/6,h*2);
             
             
                  //head
             
             
                  ellipse(x,y-h/2,w,h);
             
             
                  //eyes
             
             
                  eyeR = random(255);
             
             
                  eyeG = random(255);
             
             
                  eyeB = random(255);
             
             
                  eyeA = random(255);
             
             
                  fill (eyeR,eyeG,eyeB,eyeA);
             
             
                  ellipse(x-w/3,y-h/2,eyeSize,eyeSize*2);
             
             
                  ellipse(x+w/3,y-h/2,eyeSize,eyeSize*2);
             
             
                  //legs
             
             
                  stroke(150);
             
             
                  line(x-w/12,y+h,x-w/4,y+h+10);
             
             
                  line(x+w/12,y+h,x+w/4,y+h+10);
             
             
                }
             
             
                  //change location of zoog by speed
             
             
                  //void move() {
             
             
                  //xpos = xpos + xspeed;
             
             
                  //ypos = ypos + yspeed;
             
             
                  //if ((xpos > width) || (xpos < 0)) {
             
             
                    // xspeed = xspeed * -1;
             
             
                //}
             
             
                  //if ((ypos > height) || (ypos < 0)) {
             
             
                    // yspeed = yspeed * -1;
             
             
                //}
             
              
              
              1  
            
 
            