The Essential Guide to HTML5

(Greg DeLong) #1

HANGMAN


Code Explanation


ctx.lineTo(bodycenterx+20,110); Draws the line


ctx.stroke(); Actually draws the path


ctx.closePath(); Closes the path


} Closes the function


function drawleftarm() { Header for the function that draws the left arm


ctx.beginPath(); Starts the path


ctx.moveTo(bodycenterx,100); Moves to the position


ctx.lineTo(bodycenterx-20,110); Draws the line


ctx.stroke(); Actually draws the path


ctx.closePath(); Closes the path


} Closes the function


function drawrightleg() { Header for the function that draws the right leg


ctx.beginPath(); Starts the path


ctx.moveTo(bodycenterx,125); Moves to the position


ctx.lineTo(bodycenterx+10,155); Draws the line


ctx.stroke(); Actually draws the path


ctx.closePath(); Closes the path


} Closes the function


function drawleftleg() { Header for the function that draws the left leg


ctx.beginPath(); Starts the path


ctx.moveTo(bodycenterx,125); Moves to the position

Free download pdf