The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 5


this.sheight = sheight; .... height

this.info = info; ... info (the number
of sides)

this.draw = drawback; Specify how to draw

} Close the function

function makedeck() { Function header for
setting up the deck

var i; Used in the for loop

var acard; Variable to hold the
first of a pair of cards

var bcard; Variable to hold the
second of a pair of
cards

var cx = firstsx; Variable to hold the x
coordinate. Start out
at the first x position.

var cy = firstsy; Will hold the y
coordinate. Start out
at the first y position.

for(i=3;i<9;i++) { Loop to generate
cards for triangles
through octagons

acard = new Card(cx,cy,cardwidth,cardheight,i); Create a card and
position

deck.push(acard); Add to deck

bcard = new
Card(cx,cy+cardheight+margin,cardwidth,cardheight,i);

Create a card with the
same info, but below
the previous card on
screen

deck.push(bcard); Add to deck
Free download pdf