Make a Paddle

// Draw a Rectangle 
rect(175, 175, 60, 20);

/** 
200 Pixels from the Left side of Screen
200 Pixels Down from Top of Screen 
20 Pixels Wide
40 Pixels High 

Try tweaking the Numbers ;)
*/

Make the Paddle Move

/** Begin Draw Loop
Everything in here repeats at 30 Frames Per Second **/
draw = function(){

    // Use Mouse Coordinates to position Rectangle
    rect(mouseX, mouseY, 60, 20);

}; // End Draw Loop

Go ahead and mouse around to see the Paddle move



Lock the Paddle to the lower part of the Screen

/* Begin Draw Loop */
draw = function(){
/** Black Backgrounds save power on handheld devices ;) */
background(0); 

    rect(mouseX, 375, 60, 20);

}; // End Draw Loop


Back to Mr. G Javascript Tutorial