HTML and CSS Reference
In-Depth Information
shipImage
=
new
new
Image
();
shipImage
.
src
=
"ship.png"
shipImage
.
onload
=
eventAssetsLoaded
;
}
function
function
eventAssetsLoaded
() {
canvasApp
();
}
function
function
canvasSupport
() {
return
return
Modernizr
.
canvas
;
}
function
function
canvasApp
() {
iif
(
!
canvasSupport
()) {
return
return
;
}
var
new
Image
();
pointImage
.
src
=
"pointwhite.png"
;
function
var
pointImage
=
new
function
drawScreen
() {
context
.
fillStyle
=
'#000000'
;
context
.
fillRect
(
0
,
0
,
theCanvas
.
width
,
theCanvas
.
height
);
//Box
context
.
strokeStyle
=
'#ffffff'
;
context
.
strokeRect
(
1
,
1
,
theCanvas
.
width
-
2
,
theCanvas
.
height
-
2
);
var
var
dx
=
ship
.
endx
-
ship
.
x
;
var
var
dy
=
ship
.
endy
-
ship
.
y
;
ship
.
velocityx
=
dx
*
easeValue
;
ship
.
velocityy
=
dy
*
easeValue
;
ship
.
x
+=
ship
.
velocityx
;
ship
.
y
+=
ship
.
velocityy
;
//Draw points to illustrate path
points
.
push
({
x
:
ship
.
x
,
y
:
ship
.
y
});
for
for
(
var
var
i
=
0
;
i
<
points
.
length
;
i
++
) {
context
.
drawImage
(
pointImage
,
points
[
i
].
x
+
shipImage
.
width
/
2
,
points
[
i
].
y
,
1
,
1
);
}