Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Poker Hand

def dealHand(n):
  import random

  #Deal a poker hand using random.shuffle(range)
  dir = 'I:\Documents and Settings\Cedric Stallworth\Desktop\Job CoC\Classes\Spring 2007\CS1315\modules\cards'
  hand = makeEmptyPicture(n*80, 100)
  deck = range(1,52+1)
  random.shuffle(deck)  
  for index in range(1,n+1):
    card = makePicture(dir+"//"+ str(deck[index])+'.jpg')
    insertCard(card,1,getWidth(card),1,getHeight(card),hand,80*(index-1)+1,1)
  show(hand)


######################################################################## Helper Functions
def insertCard(source, sx_start, sx_end, sy_start, sy_end, target, tx, ty):
  targetX = tx
  for sourceX in range(sx_start, sx_end+1):
    targetY = ty
    for sourceY in range(sy_start, sy_end+1):
      sourcePixel = getPixel(source, sourceX, sourceY)
      sourceColor = getColor(sourcePixel)
      targetPixel = getPixel(target, targetX, targetY)
      setColor(targetPixel, sourceColor)
      targetY = targetY + 1
    targetX = targetX + 1


Link to this Page