Outils pour utilisateurs

Outils du site


wiki:ateliers:processing:3:pong3d
pong3d.pde
float x=50, y=50, t=3, s=2, m;
int sphereSize, barHeight;
void setup(){
  size(500, 500, P3D);
  lights();
  sphereSize = 10;
  barHeight = 100;
}
 
void draw() {
    background(255);
    m=mouseY;
    pushMatrix();
    noStroke();
    fill(255, 200, 200);
    translate(x, y, 0);
    sphere(sphereSize);
    popMatrix();
    t=x>(width-5)||x<15&&y<m+(barHeight/2)&&y>m-(barHeight/2)?-t:t; // x
    x=x<sphereSize?(width/2):x;
    s=y>(width-sphereSize)||y<sphereSize?-s:s; // y
    x+=t;
    y+=s;
    pushMatrix();
    stroke(0);
    translate(10, m, 0);
    box(5, barHeight, 20);
    popMatrix();
}
wiki/ateliers/processing/3/pong3d.txt · Dernière modification: 2016/09/11 13:16 (modification externe)