HTML and CSS Reference
In-Depth Information
we will explore what we can do if we want the moving object to change direction when it hits
something, such as a wall.
Figure 5-4
shows what
Example 5-3
looks like when it is executed in a web browser. Recall
that the points are drawn for illustration only.
Figure 5-4. Moving an object on a vector
Example 5-3
gives the full code listing.
Example 5-3. Moving on a vector
<!doctype html>
<html
<html lang=
"en"
>
<head>
<head>
<meta
<meta charset=
"UTF-8"
>
<title>
<title>
CH5EX3: Moving On A Vector
</title>
</title>
<
script src
=
"modernizr.js"
><
/script>
<
script type
=
"text/javascript"
>
window
.
addEventListener
(
'load'
,
eventWindowLoaded
,
false
false
);
function
function
eventWindowLoaded
() {
canvasApp
();
}
function
function
canvasSupport
() {