float xd = 2; float yd = -1; float zd = 1; float leftwall = 300; float topwall = 250; float backwall = 0; float xwidth = 410; float ywidth = 310; float zwidth = 210; float xpos = 0; float ypos = 0; float zpos = 0; void setup() { size(800,600,P3D); frameRate(15); } void draw() { lights(); background(250); stroke(0,0,255); translate(leftwall,topwall,backwall); noFill(); box(xwidth, ywidth,zwidth); balloon(); } void balloon() { moveballoon(); translate(xpos, ypos, zpos); fill(0); stroke(255,0,0); sphere(10); } void moveballoon() { xpos +=xd; ypos +=yd; zpos +=zd; if (xpos<-.5*xwidth) xd=-xd; if (xpos>.5*xwidth) xd = -xd; if (ypos<-.5*ywidth) yd=-yd; if (ypos>.5*ywidth) yd=-yd; if (zpos<-.5*zwidth) zd=-zd; if (zpos>.5*zwidth) zd=-zd; }