02.06.2013 Views

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

},<br />

for (var x = 0; x < alienLength; x++) {<br />

context.clearRect(aliens[x].posX, aliens[x].posY,<br />

aliens[x].img.width, aliens[x].img.height);<br />

}<br />

for (var y = 0; y < alienLength; y++) {<br />

aliens[y].posX = (dir === "right") ? aliens[y].posX + 35 :<br />

aliens[y].posX - 35;<br />

context.drawImage(aliens[y].img, aliens[y].posX,<br />

aliens[y].posY);<br />

}<br />

dirCounter++;<br />

} else {<br />

clearInterval(motionInt);<br />

dirCounter = 0;<br />

for (var z = 0; z < alienLength; z++) {<br />

context.clearRect(aliens[z].posX, aliens[z].posY,<br />

aliens[z].img.width, aliens[z].img.height);<br />

}<br />

if (aliens[alienLength - 1].posY > 530) {<br />

canvas.width = 900;<br />

context.fillStyle = "#fff";<br />

context.textAlign = "center";<br />

context.font = "bold 36px Tahoma";<br />

context.fillText("GAME OVER!", 450, 350);<br />

$(canvas).blur().unbind("keydown");<br />

} else {<br />

}<br />

for (var a = 0; a < alienLength; a++) {<br />

aliens[a].posY = aliens[a].posY + 29;<br />

}<br />

context.drawImage(aliens[a].img, aliens[a].posX,<br />

aliens[a].posY);<br />

motionInt = (dir === "right") ? setInterval(<br />

function () { alienMotion("left"); }, alienSpeed) :<br />

setInterval(function () { alienMotion("right"); },<br />

alienSpeed);<br />

[ 295 ]<br />

Chapter 10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!