class bat { void drawme(){ fill(255); rect(190, 380, 40, 8); } void controlme(){ //draw the rect to hide the previous bat position fill(30); //same as background rect(0,380,400,8); //draw the bat and stop it from exiting the screen if (mouseX<5){ fill(255); rect(5,380,40,8); }else if (mouseX>355){ fill(255); rect(355,380,40,8); } else { fill(255); rect(mouseX,380,40,8); //main bat } } }