. "put the deck graphics on the vlayer"
set "deck_x" to 0
set "deck_y" to 2
put "@Deck2.mzm" Image_file p02 at "deck_x" "deck_y"
. "define constants for deck: number of cards, number of ranks per suit, and card dimensions"
set "deck_size" to "(52-1)"
set "hand_size" to 0
set "card_ranks" to 13
set "card_width" to 10
set "card_height" to 9
. "sprites stack left to right, like cards fanned in hand"
set "spr_yorder" to 1
. "Initialize the deck"
loop start
set "deck_card&loopcount&" to "loopcount"
set "card&loopcount&_suit" to "('loopcount'/'card_ranks')"
set "card&loopcount&_rank" to "('loopcount'%'card_ranks'+1)"
set "spr&loopcount&_vlayer" to 1
set "spr&loopcount&_refx" to "('card_width'*('loopcount'%'card_ranks')+'deck_x')"
set "spr&loopcount&_refy" to "('card_height'*('loopcount'/'card_ranks')+'deck_y')"
set "spr&loopcount&_width" to "card_width"
set "spr&loopcount&_height" to "card_height"
loop for "deck_size"
end
: "keyd"
. "make sure we still have a card to retrieve"
if "deck_size" < 0 then "deckedout"
. "local = deck position of card we're about to pick up"
set "local" to random 0 to "deck_size"
. "add the card to the hand"
set "hand_card&hand_size&" to "deck_card&local&"
put c?? Sprite "hand_card&hand_size&" at "('hand_size'*2)" 0
inc "hand_size" by 1
. "remove the card from the deck"
set "deck_card&local&" to "deck_card&deck_size&"
dec "deck_size" by 1
end
: "deckedout"
* "No more cards to draw!"
end
Current problem: sprites still aren't stacking nicely. Cards seem to be picked just fine, but the display is a mess. Sometimes they fan perfectly for a few draws, and then spaz out. I need a "spr_xorder" instead of "spr_yorder"...

Help







