void setup() { size(320, 240); background(153); rectMode(CENTER); } int xpos = 160; void draw(){ background(204); //right if(mouseX > width/2){ xpos ++; if(xpos > width){ xpos = width; } } //left if (mouseX < width/2){ xpos --; if(xpos < 0){ xpos = 0; } } rect(xpos, height/2, 50, 50); }