Game Development Reference
In-Depth Information
Listing 5-22. HTML File for Veggie Match
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="../../lib/easeljs-0.7.1.min.js"></script>
<script src="../../lib/preloadjs-NEXT.min.js"></script>
<script src="../../lib/tweenjs-0.5.1.min.js"></script>
<script src="memory.js"></script>
</head>
<body onload="preload()">
<canvas id="canvas" width="650" height="650" style="border: black solid 1px"></canvas>
</body>
</html>
Initializing the Game
A series of game variables is first declared, and a preload function is used to load in bitmaps before initializing the
game (see Listing 5-23).
Listing 5-23. Game Variables and Preload Function to Load in all Graphics
var stage, queue;
var faces = ['garlic', 'onion', 'pepper', 'potato', 'spinach', 'tomato'];
var cards = [];
var cardsFlipped = [];
var matches = 0;
function preload() {
queue = new createjs.LoadQueue();
queue.addEventListener("complete", init);
queue.loadManifest([
{id:"shell", src:"img/card.png"},
{id:"back", src:"img/back.png"},
{id:"garlic", src:"img/garlic.png"},
{id:"onion", src:"img/onion.png"},
{id:"pepper", src:"img/pepper.png"},
{id:"potato", src:"img/potato.png"},
{id:"spinach", src:"img/spinach.png"},
{id:"tomato", src:"img/tomato.png"}
]);
}
 
Search WWH ::




Custom Search