class Particle { float posX, posY; // position variables int posXround, posYround; // rounded position variables float speedX, speedY; // speed variables float scaleFactor = 1; float inSpeed = s5p*1.0; // initial speed variable float ffb = 0; float ffFactor = 10; // determines moment when a freefall should take place boolean ff = false; float grav = 9.8; // gravity constant float fricWall = 5; // friction constant // reading from image float s1,s2,s3,s4,s5,s6,s7,s8,s9; int vX, vY; // surface curvature vectors (based on brightness) float satP = 0; Particle (float x, float y, float fW) { posX = x; posY = y; posXround = int(posX); posYround = int(posY); speedX = 0; speedY = 2; // fricWall = fW; } void update(){ // PARTICLE POSITION if (posX > 107 && posX < 493) { posX += speedX*s6p*(s5p*2); posXround = int(posX); } else if (posX < 102) { posX = 108; posXround = int(posX); } else { posX = 489; posXround = int(posX); } if (posY > 107 && posY <= 490) { posY += speedY*(s5p*2); posYround = int(posY); } else if (posYround >= 490) { posY = 108; speedY = inSpeed; posYround = int(posY); posX = random(106,494); posXround = int(posX); ff = false; } fill(60,100,100,30); rect(posXround, posYround, 5, 5); //println(diffY); fill(60,100,0,20); // definition speedX if ((posYround-105)*390+(posXround-105) < 152100) { satP = (100.0-sS[(posYround-105)*390+(posXround-105)])/100.0; vX = sVx[(posYround-105)*390+(posXround-105)]; // vector force x direction speedX = (vX/2)*satP; // x speed update // define speedY vY = sVy[(posYround-105)*390+(posXround-105)]; // vector force y direction if ( ((-vY/2) + (grav-fricWall)) * satP > 0) { speedY = (((-vY/2) + (grav-fricWall)))*satP; // y speed update } else { speedY = .25; } } else { satP = 0; vX = vX; vY = vY; } /* // definition speed freefall if (ff == true) { if (s5 >= ffb) { ff = true; fill(0,100,0,90); } else{ ff = false; } if(ff) { speedY = grav; // println("freefall!"); } if(!ff) { speedY = grav-fW; if (s5 >=ffb) { ff = true; } } } if (ff == false) { speedY = grav-fW; // println("not freefalling"); if (diffY > ffFactor) { // println("diffY > ffFactor"); ff = true; ffb = s5; } } // println("diffY= " + diffY + " s5 = " + s5 + " ffb = " + ffb); */ } }