We are about to switch to a new forum software. Until then we have removed the registration on this forum.
What kind of code should I use to make an object bounce around the "box" ?
Processing code?
Check out http://processing.org/examples/ under the heading Motion.
float px,py,pz,vx,vy,vz; void setup(){ size(220,220,P3D); vx=random(-1,1); vy=random(-1,1); vz=random(-1,1); } void draw(){ background(0); translate(110,110,-20); rotateX(map(mouseY,0,height,-PI,PI)); rotateY(map(mouseX,0,width,-PI,PI)); noFill(); stroke(255); box(100); px+=vx;py+=vy;pz+=vz; if(abs(px)>45)vx*=-1; if(abs(py)>45)vy*=-1; if(abs(pz)>45)vz*=-1; translate(px,py,px); fill(255,0,0); noStroke(); box(10); }
I just don't know why it isn't bouncing in random directions?
How cool the example! I've got 1 online, but it doesn't rotate the big cube: :( http://studio.processingtogether.com/sp/pad/export/ro.9o1T5z1ghf2s7/latest
Answers
Processing code?
Check out http://processing.org/examples/ under the heading Motion.
I just don't know why it isn't bouncing in random directions?
How cool the example! I've got 1 online, but it doesn't rotate the big cube: :(
http://studio.processingtogether.com/sp/pad/export/ro.9o1T5z1ghf2s7/latest