class Ball{ float x = 10; float y = 10; float xSpeed = random(-4,4); float ySpeed = random(-4,4); float groesse = random(20,50); float rotation; Ball(float _x, float _y){ x = _x; y = _y; } float distanz; void display(){ rotation = atan2(mouseY-y, mouseX-x); x = x+xSpeed; y = y+ySpeed; if((x>width)|| (x < 0)){ xSpeed = xSpeed *-1; } if((y>height) || (y<0)){ ySpeed = ySpeed *-1; } pushMatrix(); translate(x,y); rotate(rotation); image(c,-groesse/2,-groesse/2, groesse, groesse); popMatrix(); } }