Game Development Reference
In-Depth Information
The JavaScript file BasicExample.js then contains the following code:
changeCanvasColor = function () {
var canvas = document.getElementById("mycanvas");
var context = canvas.getContext("2d");
context.fillStyle = "blue";
context.fillRect(0, 0, canvas.width, canvas.height)
}
document.addEventListener('DOMContentLoaded', changeCanvasColor);
In many cases, it's desirable to do this. By separating the script code from the HTML document, it's
much easier to locate the code or use it on different web sites. All the examples used in this topic
have the JavaScript code separated from the HTML document, nicely organized in one or more
JavaScript files.
What You Have Learned
In this chapter, you have learned:
How computers work, and that they consist of processors to compute things
and memory to store things
How programming languages have evolved from Assembler languages to
modern programming languages such as JavaScript
How to create a simple web application using HTML5 and JavaScript
 
Search WWH ::




Custom Search