int incPx = 300; //// PADDLE X POSITION int incPy = 550; //// PADDLE Y POSITION int incBx = 10; //// BALL X POSITION float incBy = 10; //// BALL Y POSITION void setup() { size (800, 600); } void draw() { background(0); fill(255, 0, 0); text (incPx, incPx, incPy-15); text("X", incPx+25, incPy-15); text (incPy, incPx+50, incPy-15); text("Y", incPx+75, incPy-15); fill(0, 0, 255); text (incBx, 50, 50-15); text("X", 50+25, 50-15); text (incBy, 50+50, 50-15); text("Y", 50+90, 50-15); paddle(); ball(); collision(); } void paddle() { fill(255, 0, 0); rectMode(CENTER); rect(incPx, incPy, 150, 30); if (keyPressed) { if (key == 'd' || key == 'D') { if (incPx <= width-90) { incPx+=7; } } if (key== 'a' || key == 'A') { if (incPx >=90) { incPx-=7; } } } } float xspeed,yspeed; void ball() { fill(0, 0, 255); ellipseMode(CORNER); ellipse(incBx, incBy, 25, 25); } boolean righthit; boolean centerhit; boolean lefthit; void collision() { if (incBx >= incPx-100 & incBx <= incPx-50 && incBy == incPy-30) { /// THIS IS THE LEFT SIDE OF PADDLE lefthit = true; } if (incBx >= incPx-50 & incBx <= incPx+25 && incBy == incPy-30) { /// THIS IS THE CENTER OF THE PADDLE centerhit = true; } if (incBx >= incPx+25 & incBx <= incPx+75 && incBy == incPy-30) { /// THIS IS THE RIGHT SIDE OF THE PADDLE righthit = true; } }