Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.65 KB | None | 0 0
  1. # Memory game to learn pygame features
  2. import pygame, sys, random
  3. from pygame.locals import *
  4.  
  5. # VARIABLES
  6. WINDOWwIDTH = 640
  7. WINDOWHEIGHT = 480
  8. BOXSIZE = 40
  9. GAPSIZE = 10
  10. BOARDWIDTH = 10  # NUMBER OF COLUMNS
  11. BOARDHEIGHT = 7  # NUMBER OF ROWS
  12.  
  13. XMARGIN = int((WINDOWWIDTH - (BOARDWIDTH * (BOXSIZE + GAPSIZE))) / 2)
  14. YMARGIN = int((WINDOWHEIGHT - (BOARDHEIGHT * (BOXSIZE + GAPSIZE))) / 2)
  15.  
  16. # COLORS
  17. GRAY     = (100, 100, 100)
  18. NAVYBLUE = ( 60,  60, 100)
  19. WHITE    = (255, 255, 255)
  20. RED      = (255,   0,   0)
  21. GREEN    = (  0, 255,   0)
  22. BLUE     = (  0,   0, 255)
  23. YELLOW   = (255, 255,   0)
  24. ORANGE   = (255, 128,   0)
  25. PURPLE   = (255,   0, 255)
  26. CYAN     = (  0, 255, 255)
  27.  
  28. BACKGROUND = NAVYBLUE
  29. BOXCOLOR = WHITE
  30. HIGHLIGHTCOLOR = BLUE
  31.  
  32. #SHAPES
  33. DONUT = 'donut'
  34. SQUARE = 'square'
  35. DIAMOND = 'diamond'
  36. LINES = 'lines'
  37. OVAL = 'oval'
  38.  
  39. ALLCOLORS =  (RED, GREEN, BLUE, YELLOW, ORANGE, PURPLE, CYAN)
  40. ALLSHAPES = (DONUT, SQUARE, DIAMOND, LINES, OVAL)
  41.  
  42.  
  43. # LOCAL FUNCTIONS
  44. def generateRevealedBoxesData(value):
  45.     # .....
  46. def getRandomizedBoard():
  47.     # get a list of every possible shape and color combination
  48.     images = []
  49.     for color in ALLCOLORS:
  50.         for shape in ALLSHAPES:
  51.             images.append( (shape, color) )
  52.            
  53.     random.shuffle(images)
  54.     numImages = int((BOARDWIDTH * BOARDHEIGHT)/2)
  55.     images = images[:numImages] * 2
  56.     random.shuffle(images)
  57.     # create a random board with randomly placed icons
  58.     board = []
  59.     for x in range(BOARDWIDTH):  # for every column
  60.         column = []
  61.         for y in range(BOARDHEIGHT):    # for every row
  62.             column.append(images[0])    # add image to board
  63.             del images[0]               # remove from list
  64.         board.append(column)            # add column to list
  65.     return board
  66.        
  67.  
  68. #def splitIntoGroupsOf(groupSize, List):
  69. def leftTopCoordsOfBox(x, y):
  70.     # turn board coordinates into pixel
  71. def getBoxAtPixel(x,y):
  72.     # turn pixel coordinates into box
  73. def drawIcon(shapem color, boxx, boxy):
  74.     #draw the imange under the box coordinates given
  75. def getShapeAndColor(board, x, y):
  76.     # getting the type of shape and color of shape
  77. def drawBoxCovers(board,boxes, cover)
  78.     # draws over image to reveal/conceal the image
  79. def revealBoxesAnimation(board, boxesToReveal):
  80.     # reveal the image
  81. def coverBoxesAnimation(board, boxestoCover):
  82.     # cover the image
  83. def drawBoard(board, revealed)
  84.     # draws board with appropriate covered/revealed pieces
  85. def drawHighlightBox(x,y):
  86.     # draws a simple highlight around box
  87. def hasWon(revealedBoxes):
  88.     # check if all boxes are revealed
  89. # MAIN
  90. def main():
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement