HTML and CSS Reference
In-Depth Information
Figure 8-1. As the character moves, only the tiles that the character was on top of are being repainted
In order to show how this concept works in a practical application, you're going to develop a very simple
application that draws a somewhat complex background and a small red dot that you'll be able to control using the
arrow keys or keys W, A, S, and D. See Listing 8-7.
Listing 8-7. Canvas Application Demo
window.addEventListener('keydown', function(e) {
switch(e.keyCode) {
case 65: // A
console.log('Go left!');
break;
case 68: // D
console.log('Go right!');
break;
 
Search WWH ::




Custom Search