HTML and CSS Reference
In-Depth Information
var
var
end
=
graph
.
nodes
[
endNode
.
x
][
endNode
.
y
];
var
false
);
This will result in
Figure 8-16
, showing the path running through a grass tile because it does
not add enough to the total path cost to force a new direction change.
var
result
=
astar
.
search
(
graph
.
nodes
,
start
,
end
,
false
Figure 8-16.
Example 8-16
—A* with grass tiles
Example 8-16. Larger A* example with grass tiles
<!doctype html>
<html
<html lang=
"en"
>
<head>
<head>
<meta
<meta charset=
"UTF-8"
>
<title>
<title>
Chapter 8 Example 16 - Larger A* Example with Grass Tiles
</title>
</title>
<
script src
=
"modernizr.js"
><
/script>
<
script type
=
'text/javascript'
src
=
'graph.js'
><
/script>
<
script type
=
'text/javascript'
src
=
'astar.js'
><
/script>
<
script type
=
"text/javascript"
>
window
.
addEventListener
(
'load'
,
eventWindowLoaded
,
false
false
);
function
function
eventWindowLoaded
() {
canvasApp
();
}