Making 3D walls visible

I have a 3d box bouncing sim, with a camera around the mouse. anyways i want to make the walls different colors so u can tell its 3d, heres my code.

float x;
float y;
int xa;
int xb;
int xdirection = 1;
int ydirection = 1;
int textsize;
float rad=50;
PImage img;
float rotate;
int z;
int d;
int rect;
void setup() {
x=random(-12, 12);
y=random(-12, 12);

size(700, 600, P3D);
frameRate (60);


void draw() {

camera(mouseX, mouseY, 700, 200, 300, 350,
-1, -1, -1);

if (x> width-rad) {


if (y>height-rad) {
if (y < 0) {
if (x < 0) {
fill(0, 0, 255);
translate(x, y, z);

rotate=rotate +1;

Well for starters, the rectangle you declared at the beginning isn’t visible because the console is reading the lines in order, meaning it will first display a rectangle, then display the background (erasing the whole canvas and coloring it 200,200,200), then display the sphere. You want to display the background before displaying anything else :slight_smile:

As for getting each wall to be a different color, this can easily be achieved by just running a fill command before displaying each wall, with the color in the fill() corresponding to the color of aforementioned wall.

Finally, and this is more of a precaution than anything, looking into it, the rectangle function seems to be a bit…inconsistent in P3D mode. While I’ll admit I’m not that experienced with the 3D feature of processing, the camera doesn’t seem to quite work right when drawing rectangles. If you find yourself unable to fix the problems that arise from using rect(), I recommend using the box command as a substitute, and having one of the box’s 3 dimensions being either 0 or some very small number.

thanks ill give it a try when i get the chance!

After background please try using lights (); because looks better