class Bille{ Vecteur pos,vit,posforce,force; boolean attraction; color couleur; float viscosite=-0.43f; public Bille(float x,float y,color c){ pos=new Vecteur(x,y,0); vit=new Vecteur(0,0,0); couleur=c; attraction=false; } public void dessiner(){ limiter(); pushMatrix(); translate(pos.x,pos.y,rayon); noStroke(); fill(couleur); sphere(rayon); translate(0,0,-rayon+2); rotateZ(-PI/5); fill(50,30); ellipse(5,25,40,60); fill(30,20); ellipse(5,20,30,60); fill(105,255,0); popMatrix(); } public void avancer(){ force=vit.cloner().mul(viscosite*0.1f); vit=vit.ajouter(force,0.1f); pos=pos.ajouter(vit,0.1f); if(vit.length()<2) vit.place(0,0,0); } void limiter(){ if(pos.x+rayon>dx){ pos.x=dx-rayon; vit.x*=-1; } if(pos.x-rayon<-dx){ pos.x=-dx+rayon; vit.x*=-1; } if(pos.y+rayon>dy){ pos.y=dy-rayon; vit.y*=-1; } if(pos.y-rayon<-dy){ pos.y=-dy+rayon; vit.y*=-1; } } }