sketch not running on processing.js but working on pc compiler

edited June 2016 in JavaScript Mode

Well, this is the code of a program that I have, that is working fine on the compiler in pc, but not in all the online sites that I already try ! , I have not a clue

int x, count=0 ,rot;
boolean ki = false;
boolean rele;
Paint [] mypaint = new Paint [100];
void setup () {
   size(1280,720);
  background(random(255));
  for (x=0; x<mypaint.length; x ++ ) {
    rect(x, x, x, x);
    mypaint[x] = new Paint(color(random(255),random(255),random(255),155), width/2, height/2, 5,0,0);
  }
}
void draw() {
//background(random(255))
  x=0;
   if (key == 'o'){
  ki=false;
 } 
  do
  {
    if (ki==true){
   mypaint[x].move();
   mypaint[x].display(); 
   x++;
   }
   }
  while (x<count);

  /*if (mousePressed == true) {
    ki =true;
    if (count == mypaint.length) {
      count= 0;
    }
    mypaint[count].setPos();
    count++;
  }*/
}
void mousePressed() {
  background(mouseX,mouseY,230);
  ki =true;
  rele = false;
  if (count == mypaint.length) {
    count= 0;
  }
  mypaint[count].setPos();
  count++;
}
void mouseReleased(){
  rele = true;
}

class Paint {
  color c;
  float xpos;
  float ypos;
  float wp;
  float hp;
  float speed;
  Paint(color tempc, float tempXpos, float tempYpos, float tempspeed,float tempwp, float temphp) {
    c = tempc;
    xpos = tempXpos;
    ypos = tempYpos;
    speed =tempspeed;
    hp = temphp;
    wp= tempwp;
  }
  void display() {

    pushMatrix();
    noStroke();
   // setColor();
    fill(c);
    rot++;

    translate(width/2,height/2);
    rotate(radians(rot));
   // scale(mouseX * 0.3);
    wp= (width/2 -mouseX) * 0.30;
    hp= (height/2 -mouseY) * 0.30;
    ellipseMode(CENTER);
    ellipse(xpos, ypos, wp, hp);
  //  ellipse(width-xpos,height-ypos, wp,hp);
   // ellipse(xpos,height-ypos, wp,hp);
  //  ellipse(width-xpos,ypos, wp,hp);
   // rect(xpos+40,ypos+40,wp,hp);
    popMatrix();
    //rect(xpos, ypos, 50, 50);
  }
  void move() {

  /* xpos++;
    ypos++;*/
  }
  void setColor(){
   // fill(random(mouseY),random(mouseY),random(mouseY),mouseX);

  }
  void setPos() {
   // pushMatrix();
    translate(width/2,height/2);
    xpos = width/2 - mouseX;
    ypos = height/2 -mouseY;
   // popMatrix();
  }
}

Answers

Sign In or Register to comment.