Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. import pygame, sys
  2. from pygame.locals import *
  3.  
  4.  
  5. #Magic numbers
  6. fps = 30
  7. winW = 640
  8. winH = 480
  9. boxSize = 40
  10. gapSize = 75
  11. boardW = 3
  12. boardH = 3
  13. xMargin = int((winW - (boardW * (boxSize + gapSize))) / 2)
  14. yMargin = int((winW - (boardW * (boxSize + gapSize))) / 2)
  15. #Lil bit o' color R G B
  16. NAVYBLUE = ( 60, 60, 100)
  17. correctCords = [[175,275,375],[375,275,175]]
  18. bgColor = NAVYBLUE
  19.  
  20. unC = pygame.image.load("unC.png")
  21. cor = pygame.image.load("correct.png")
  22. inc = pygame.image.load("wrong.png")
  23. correct = "Correct"
  24. inCorrect = "Incorrect"
  25.  
  26. def main():
  27. global FPSCLOCK, DISPLAYSURF
  28. pygame.init()
  29. FPSCLOCK = pygame.time.Clock()
  30. DISPLAYSURF = pygame.display.set_mode((winW, winH))
  31. mousex = 0 #stores x-coordinate of mouse event
  32. mousey = 0 #stores y-coordinate of mouse event
  33. pygame.display.set_caption("Branches")
  34.  
  35. DISPLAYSURF.fill(bgColor)
  36. gridGame(inCorrect, correct,gapSize,xMargin,yMargin,boxSize)
  37.  
  38. while True:
  39. mouseClicked = False
  40.  
  41.  
  42. for event in pygame.event.get():
  43. if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
  44. pygame.quit()
  45. sys.exit()
  46. elif event.type == MOUSEMOTION:
  47. mousex,mousey = event.pos
  48. elif event.type == MOUSEBUTTONUP:
  49. mousex, mousey = event.pos
  50. pos = pygame.mouse.get_pos()
  51. mouseClicked = True
  52. unCa = unC.get_rect()
  53. corA = cor.get_rect()
  54. print unCa
  55. print corA
  56. print pos
  57. if unCa.collidepoint(pos):
  58. DISPLAYSURF.blit(cor,(mousey,mousex))
  59.  
  60. """lada = unC.get_rect()
  61. lada =
  62. if mousex and mousey == lada:
  63. for x in correctCords:
  64. for y in x:
  65. for z in x:
  66. if mousey and mousex == z and y:
  67.  
  68. DISPLAYSURF.blit(cor,(mousey,mousex))
  69. print lada"""
  70.  
  71.  
  72.  
  73. pygame.display.update()
  74. FPSCLOCK.tick(fps)
  75.  
  76.  
  77. def gridGame(inCorrect, correct,gapSize,xMargin,yMargin,boxSize):
  78. grid = []
  79. cordX = []
  80. cordY = []
  81. correctRecs = []
  82. #cordinates = []
  83. #cordinates.append([])
  84. #cordinates.append([])
  85. #cordinates.append([])
  86. #this is basically getBoard() all over again
  87. #This part will arrange the actual backend grid
  88. for row in range(3):
  89. grid.append([])
  90. #cordinates[0].append(gapSize+(row+1)*100)
  91. #cordinates[1].append(gapSize+(row+1)*100)
  92. #cordinates[2].append(gapSize+(row+1)*100)
  93. for column in range(3):
  94. grid[row].append(inCorrect)
  95.  
  96.  
  97. for row in range(3):
  98. cordX.append([])
  99. for column in range(3):
  100. cordX[row].append(gapSize+(row+1)*100)
  101.  
  102. for row in range(3):
  103. cordY.append([])
  104. for column in range(3):
  105. cordY[row].append(gapSize+(column+1)*100)
  106. #print cordX[0][0], cordY[0][0]
  107.  
  108.  
  109.  
  110. grid[0][2] = correct
  111. grid[1][1] = correct
  112. grid[2][0] = correct
  113. #Y-AXEL SKRIVS FoRST ([Y][X])
  114.  
  115. #print cordinates[2][1]
  116. DISPLAYSURF.blit(cor,(100,100))
  117.  
  118.  
  119.  
  120. #Let's draw it as well
  121. for row in range(3):
  122. for column in range(3):
  123. DISPLAYSURF.blit(unC,(gapSize+(row+1)*100,gapSize+(column+1)*100))
  124. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement