Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2020 (edited)
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.05 KB | None | 0 0
  1. import pygame,random
  2. pygame.init()
  3.  
  4. # draw our window
  5. window = pygame.display.set_mode((500,540),pygame.NOFRAME)
  6. pygame.display.set_caption("Tic Tac TOE")
  7.  
  8.  
  9.  
  10. MANUAL_CURSOR = pygame.image.load('nw.png').convert_alpha()
  11.  
  12.  
  13. MANUAL_CURSOR2 = pygame.image.load('nOW.png').convert_alpha()
  14.  
  15.  
  16.  
  17. bg = pygame.image.load("mai.png")
  18. fps = 40
  19.  
  20. clock = pygame.time.Clock()
  21.  
  22.  
  23.  
  24.  
  25. class button():
  26. def __init__(self, color, x,y,width,height, text=''):
  27. self.color = color
  28. self.x = x
  29. self.y = y
  30. self.width = width
  31. self.height = height
  32. self.rect = pygame.Rect(x,y,height,width)
  33. self.text = text
  34. self.over = False
  35.  
  36. def draw(self,window,outline=None):
  37. #Call this method to draw the button on the screen
  38. if outline:
  39. pygame.draw.rect(window, outline, (self.x-2,self.y-2,self.width+4,self.height+4),0)
  40.  
  41. pygame.draw.rect(window, self.color, (self.x,self.y,self.width,self.height),0)
  42.  
  43. if self.text != '':
  44. font = pygame.font.SysFont('comicsans', 60)
  45. text = font.render(self.text, 1, (0,0,0))
  46. window.blit(text, (self.x + (self.width/2 - text.get_width()/2), self.y + (self.height/2 - text.get_height()/2)))
  47.  
  48. def isOver(self, pos):
  49. #Pos is the mouse position or a tuple of (x,y) coordinates
  50. if pos[0] > self.x and pos[0] < self.x + self.width:
  51. if pos[1] > self.y and pos[1] < self.y + self.height:
  52. return True
  53.  
  54. return False
  55.  
  56. def playSoundIfMouseIsOver(self, pos, sound):
  57. if self.isOver(pos):
  58. if not self.over:
  59. beepsound.play()
  60. self.over = True
  61. else:
  62. self.over = False
  63.  
  64. def getResult( self ):
  65. return self.text
  66.  
  67.  
  68.  
  69.  
  70.  
  71. def winner( b1, b2, b3, b4, b5, b6, b7, b8, b9 ):
  72. """ Given the buttons 1-9 in order from top-left to bottom right
  73. return whether 'x' or 'o' has won the game, or None and which
  74. line/row/vertical the win was made on """
  75. winner = ( None, None )
  76. # make a grid of the board-state for iteration
  77. board = [ [ b1.getResult(), b2.getResult(), b3.getResult() ],
  78. [ b4.getResult(), b5.getResult(), b6.getResult() ],
  79. [ b7.getResult(), b8.getResult(), b9.getResult() ] ]
  80. # check the horizontals
  81. for row in range( 3 ):
  82. if ( board[row][0] != '' and
  83. board[row][0] == board[row][1] and board[row][0] == board[row][2] ):
  84. winner = ( board[row][0], 'h'+str( row ) )
  85. break
  86. # check the verticals
  87. for col in range( 3 ):
  88. if ( board[0][col] != '' and
  89. board[0][col] == board[1][col] and board[0][col] == board[2][col] ):
  90. winner = ( board[col][0], 'v'+str( col ) )
  91. break
  92. # diagonals
  93. if ( board[1][1] != '' ):
  94. if ( board[0][0] == board[1][1] and board[2][2] == board[1][1] ):
  95. winner = ( board[1][1], 'd1' )
  96. elif ( board[0][2] == board[1][1] and board[2][0] == board[1][1] ):
  97. winner = ( board[1][1], 'd2' )
  98. return winner
  99.  
  100.  
  101.  
  102.  
  103. class Partic:
  104. def __init__(self,x,y,height,width,color):
  105. self.x = x
  106. self.y = y
  107. self.height = height
  108. self.width = width
  109. self.color = color
  110. self.partilight = pygame.image.load("noW.png")
  111. self.rect = pygame.Rect(x,y,height,width)
  112. def draw(self):
  113. self.rect.topleft = (self.x,self.y)
  114. pygame.draw.rect(window,self.color,self.rect)
  115. window.blit(self.partilight,self.rect)
  116.  
  117.  
  118. class Parti:
  119. def __init__(self,x,y,height,width,color):
  120. self.x = x
  121. self.y = y
  122. self.height = height
  123. self.width = width
  124. self.color = color
  125. self.partilight = pygame.image.load("nw.png")
  126. self.rect = pygame.Rect(x,y,height,width)
  127. def draw(self):
  128. self.rect.topleft = (self.x,self.y)
  129. pygame.draw.rect(window,self.color,self.rect)
  130. window.blit(self.partilight,self.rect)
  131.  
  132.  
  133.  
  134. class line:
  135. def __init__(self,x,y,height,width,color):
  136. self.x = x
  137. self.y = y
  138. self.height = height
  139. self.width = width
  140. self.color = color
  141. self.partilight = pygame.image.load("ps1.png")
  142. self.rect = pygame.Rect(x,y,height,width)
  143. def draw(self):
  144. self.rect.topleft = (self.x,self.y)
  145. pygame.draw.rect(window,self.color,self.rect)
  146. window.blit(self.partilight,self.rect)
  147.  
  148.  
  149. class lin:
  150. def __init__(self,x,y,height,width,color):
  151. self.x = x
  152. self.y = y
  153. self.height = height
  154. self.width = width
  155. self.color = color
  156. self.partilight = pygame.image.load("ps2.png")
  157. self.rect = pygame.Rect(x,y,height,width)
  158. def draw(self):
  159. self.rect.topleft = (self.x,self.y)
  160. pygame.draw.rect(window,self.color,self.rect)
  161. window.blit(self.partilight,self.rect)
  162.  
  163. class liner:
  164. def __init__(self,x,y,height,width,color):
  165. self.x = x
  166. self.y = y
  167. self.height = height
  168. self.width = width
  169. self.color = color
  170. self.partilight = pygame.image.load("ps3.png")
  171. self.rect = pygame.Rect(x,y,height,width)
  172. def draw(self):
  173. self.rect.topleft = (self.x,self.y)
  174. pygame.draw.rect(window,self.color,self.rect)
  175. window.blit(self.partilight,self.rect)
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191. class lower:
  192. def __init__(self,x,y,height,width,color):
  193. self.x = x
  194. self.y = y
  195. self.height = height
  196. self.width = width
  197. self.color = color
  198. self.partilight = pygame.image.load("sh1.png")
  199. self.rect = pygame.Rect(x,y,height,width)
  200. def draw(self):
  201. self.rect.topleft = (self.x,self.y)
  202. pygame.draw.rect(window,self.color,self.rect)
  203. window.blit(self.partilight,self.rect)
  204.  
  205.  
  206. class lowe:
  207. def __init__(self,x,y,height,width,color):
  208. self.x = x
  209. self.y = y
  210. self.height = height
  211. self.width = width
  212. self.color = color
  213. self.partilight = pygame.image.load("sh2.png")
  214. self.rect = pygame.Rect(x,y,height,width)
  215. def draw(self):
  216. self.rect.topleft = (self.x,self.y)
  217. pygame.draw.rect(window,self.color,self.rect)
  218. window.blit(self.partilight,self.rect)
  219.  
  220. class low:
  221. def __init__(self,x,y,height,width,color):
  222. self.x = x
  223. self.y = y
  224. self.height = height
  225. self.width = width
  226. self.color = color
  227. self.partilight = pygame.image.load("sh3.png")
  228. self.rect = pygame.Rect(x,y,height,width)
  229. def draw(self):
  230. self.rect.topleft = (self.x,self.y)
  231. pygame.draw.rect(window,self.color,self.rect)
  232. window.blit(self.partilight,self.rect)
  233.  
  234.  
  235. class winner:
  236. def __init__(self,x,y,height,width,color):
  237. self.x = x
  238. self.y = y
  239. self.height = height
  240. self.width = width
  241. self.color = color
  242. self.partilight = pygame.image.load("nh1.png")
  243. self.rect = pygame.Rect(x,y,height,width)
  244. def draw(self):
  245. self.rect.topleft = (self.x,self.y)
  246. pygame.draw.rect(window,self.color,self.rect)
  247. window.blit(self.partilight,self.rect)
  248.  
  249. class win:
  250. def __init__(self,x,y,height,width,color):
  251. self.x = x
  252. self.y = y
  253. self.height = height
  254. self.width = width
  255. self.color = color
  256. self.partilight = pygame.image.load("nh2.png")
  257. self.rect = pygame.Rect(x,y,height,width)
  258. def draw(self):
  259. self.rect.topleft = (self.x,self.y)
  260. pygame.draw.rect(window,self.color,self.rect)
  261. window.blit(self.partilight,self.rect)
  262.  
  263.  
  264.  
  265.  
  266. white = (250,250,250)
  267. greenbutton2 = button((0,255,0),190,215,100,100, '2')
  268.  
  269. greenbutton3 = button((0,255,0),335,215,100,100, '3')
  270.  
  271. greenbutton4 = button((0,255,0),71,215,100,100, '4')
  272.  
  273. greenbutton5 = button((0,255,0),71,350,100,100, '5')
  274.  
  275. greenbutton6 = button((0,255,0),190,350,100,100, '6')
  276.  
  277. greenbutton7 = button((0,255,0),335,350,100,100, '7')
  278.  
  279.  
  280. greenbutton8 = button((0,255,0),70,90,100,100, '8')
  281.  
  282. greenbutton9 = button((0,255,0),190,90,100,100, '9')
  283.  
  284. greenbutton10 = button((0,255,0),335,90,100,100, '10')
  285.  
  286.  
  287. font = pygame.font.Font("fos.ttf", 60)
  288. score = 1
  289. cointext = font.render("" + str(score), True, (255,255,255))
  290. coinrect = cointext.get_rect()
  291. coinrect.center = ((100,50))
  292.  
  293. lines = []
  294.  
  295. liness = []
  296. linesss = []
  297. linessss = []
  298. partics = []
  299. parts = []
  300. lnes = []
  301. pos = pygame.mouse.get_pos()
  302. def redraw():
  303. window.fill((174, 214, 241))
  304. window.blit(bg,(0,0))
  305. greenbutton2.draw(window)
  306. greenbutton3.draw(window)
  307. greenbutton4.draw(window)
  308. greenbutton5.draw(window)
  309. greenbutton6.draw(window)
  310. greenbutton7.draw(window)
  311.  
  312. greenbutton8.draw(window)
  313. greenbutton9.draw(window)
  314. greenbutton10.draw(window)
  315.  
  316.  
  317.  
  318.  
  319. for partic in partics:
  320. partic.draw()
  321.  
  322.  
  323. for parti in parts:
  324. parti.draw()
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. pos = pygame.mouse.get_pos()
  333.  
  334.  
  335. if score >= 2:
  336. window.blit(MANUAL_CURSOR, MANUAL_CURSOR.get_rect(center = pygame.mouse.get_pos()))
  337. pygame.mouse.set_visible(False)
  338.  
  339.  
  340. if score >= 3:
  341. window.blit(MANUAL_CURSOR2, MANUAL_CURSOR2.get_rect(center = pygame.mouse.get_pos()))
  342.  
  343.  
  344. if score >= 4:
  345. window.blit(MANUAL_CURSOR, MANUAL_CURSOR.get_rect(center = pygame.mouse.get_pos()))
  346. pygame.mouse.set_visible(False)
  347.  
  348.  
  349. if score >= 5:
  350. window.blit(MANUAL_CURSOR2, MANUAL_CURSOR2.get_rect(center = pygame.mouse.get_pos()))
  351.  
  352. if score >= 6:
  353. window.blit(MANUAL_CURSOR, MANUAL_CURSOR.get_rect(center = pygame.mouse.get_pos()))
  354. pygame.mouse.set_visible(False)
  355.  
  356.  
  357. if score >= 7:
  358. window.blit(MANUAL_CURSOR2, MANUAL_CURSOR2.get_rect(center = pygame.mouse.get_pos()))
  359.  
  360.  
  361. if score >= 8:
  362. window.blit(MANUAL_CURSOR, MANUAL_CURSOR.get_rect(center = pygame.mouse.get_pos()))
  363. pygame.mouse.set_visible(False)
  364.  
  365.  
  366. if score >= 9:
  367. window.blit(MANUAL_CURSOR2, MANUAL_CURSOR2.get_rect(center = pygame.mouse.get_pos()))
  368.  
  369. if score >= 10:
  370. window.blit(MANUAL_CURSOR, MANUAL_CURSOR.get_rect(center = pygame.mouse.get_pos()))
  371. pygame.mouse.set_visible(False)
  372.  
  373.  
  374.  
  375. window.blit(cointext,coinrect)
  376. for line in lines:
  377. line.draw()
  378.  
  379.  
  380.  
  381. green = (105,200,100)
  382.  
  383. def turns():
  384.  
  385.  
  386. if score == 2:
  387. if greenbutton2.isOver(pos):
  388. partics.append(Partic(190,215,100,100,white))
  389.  
  390.  
  391. if score == 2:
  392. if greenbutton3.isOver(pos):
  393. partics.append(Partic(335,215,100,100,white))
  394.  
  395.  
  396.  
  397.  
  398.  
  399. if score == 2:
  400. if greenbutton4.isOver(pos):
  401. partics.append(Partic(71,215,100,100,white))
  402.  
  403.  
  404.  
  405.  
  406. if score == 2:
  407. if greenbutton5.isOver(pos):
  408. partics.append(Partic(71,350,100,100,white))
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415. if score == 2:
  416. if greenbutton6.isOver(pos):
  417. partics.append(Partic(190,350,100,100,white))
  418.  
  419.  
  420. if score == 2:
  421. if greenbutton7.isOver(pos):
  422. partics.append(Partic(335,350,100,100,white))
  423.  
  424.  
  425.  
  426. if score == 2:
  427. if greenbutton8.isOver(pos):
  428. partics.append(Partic(70,90,100,100,white))
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435. if score == 2:
  436. if greenbutton9.isOver(pos):
  437. partics.append(Partic(190,90,100,100,white))
  438.  
  439.  
  440.  
  441.  
  442.  
  443. if score == 2:
  444. if greenbutton10.isOver(pos):
  445. partics.append(Partic(335,90,100,100,white))
  446.  
  447. #===================================================================================
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454. if score == 3:
  455. if greenbutton2.isOver(pos):
  456. parts.append(Parti(190,215,100,100,white))
  457.  
  458.  
  459. if score == 3:
  460. if greenbutton3.isOver(pos):
  461. parts.append(Parti(335,215,100,100,white))
  462.  
  463.  
  464. if score == 3:
  465. if greenbutton4.isOver(pos):
  466. parts.append(Parti(71,215,100,100,white))
  467.  
  468.  
  469. if score == 3:
  470. if greenbutton5.isOver(pos):
  471. parts.append(Parti(71,350,100,100,white))
  472.  
  473. if score == 3:
  474. if greenbutton6.isOver(pos):
  475. parts.append(Parti(190,350,100,100,white))
  476.  
  477.  
  478. if score == 3:
  479. if greenbutton7.isOver(pos):
  480. parts.append(Parti(335,350,100,100,white))
  481.  
  482. if score == 3:
  483. if greenbutton8.isOver(pos):
  484. parts.append(Parti(70,90,100,100,white))
  485.  
  486. if score == 3:
  487. if greenbutton9.isOver(pos):
  488. parts.append(Parti(190,90,100,100,white))
  489.  
  490.  
  491. if score == 3:
  492. if greenbutton10.isOver(pos):
  493. parts.append(Parti(335,90,100,100,white))
  494.  
  495. # -------------------------------------------------------------------------------
  496.  
  497. if score == 4:
  498. if greenbutton2.isOver(pos):
  499. partics.append(Partic(190,215,100,100,white))
  500.  
  501.  
  502. if score == 4:
  503. if greenbutton3.isOver(pos):
  504. partics.append(Partic(335,215,100,100,white))
  505.  
  506.  
  507.  
  508.  
  509.  
  510. if score == 4:
  511. if greenbutton4.isOver(pos):
  512. partics.append(Partic(71,215,100,100,white))
  513.  
  514.  
  515.  
  516.  
  517. if score == 4:
  518. if greenbutton5.isOver(pos):
  519. partics.append(Partic(71,350,100,100,white))
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526. if score == 4:
  527. if greenbutton6.isOver(pos):
  528. partics.append(Partic(190,350,100,100,white))
  529.  
  530.  
  531. if score == 4:
  532. if greenbutton7.isOver(pos):
  533. partics.append(Partic(335,350,100,100,white))
  534.  
  535.  
  536.  
  537. if score == 4:
  538. if greenbutton8.isOver(pos):
  539. partics.append(Partic(70,90,100,100,white))
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546. if score == 4:
  547. if greenbutton9.isOver(pos):
  548. partics.append(Partic(190,90,100,100,white))
  549.  
  550.  
  551.  
  552.  
  553.  
  554. if score == 4:
  555. if greenbutton10.isOver(pos):
  556. partics.append(Partic(335,90,100,100,white))
  557.  
  558. #===================================================================================
  559.  
  560. if score == 5:
  561. if greenbutton2.isOver(pos):
  562. parts.append(Parti(190,215,100,100,white))
  563.  
  564.  
  565. if score == 5:
  566. if greenbutton3.isOver(pos):
  567. parts.append(Parti(335,215,100,100,white))
  568.  
  569.  
  570. if score == 5:
  571. if greenbutton4.isOver(pos):
  572. parts.append(Parti(71,215,100,100,white))
  573.  
  574.  
  575. if score == 5:
  576. if greenbutton5.isOver(pos):
  577. parts.append(Parti(71,350,100,100,white))
  578.  
  579. if score == 5:
  580. if greenbutton6.isOver(pos):
  581. parts.append(Parti(190,350,100,100,white))
  582.  
  583.  
  584. if score == 5:
  585. if greenbutton7.isOver(pos):
  586. parts.append(Parti(335,350,100,100,white))
  587.  
  588. if score == 5:
  589. if greenbutton8.isOver(pos):
  590. parts.append(Parti(70,90,100,100,white))
  591.  
  592. if score == 5:
  593. if greenbutton9.isOver(pos):
  594. parts.append(Parti(190,90,100,100,white))
  595.  
  596.  
  597. if score == 5:
  598. if greenbutton10.isOver(pos):
  599. parts.append(Parti(335,90,100,100,white))
  600.  
  601. # -------------------------------------------------------------------------------
  602.  
  603. # -------------------------------------------------------------------------------
  604.  
  605. if score == 6:
  606. if greenbutton2.isOver(pos):
  607. partics.append(Partic(190,215,100,100,white))
  608.  
  609.  
  610. if score == 6:
  611. if greenbutton3.isOver(pos):
  612. partics.append(Partic(335,215,100,100,white))
  613.  
  614.  
  615.  
  616.  
  617.  
  618. if score == 6:
  619. if greenbutton4.isOver(pos):
  620. partics.append(Partic(71,215,100,100,white))
  621.  
  622.  
  623.  
  624.  
  625. if score == 6:
  626. if greenbutton5.isOver(pos):
  627. partics.append(Partic(71,350,100,100,white))
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634. if score == 6:
  635. if greenbutton6.isOver(pos):
  636. partics.append(Partic(190,350,100,100,white))
  637.  
  638.  
  639. if score == 6:
  640. if greenbutton7.isOver(pos):
  641. partics.append(Partic(335,350,100,100,white))
  642.  
  643.  
  644.  
  645. if score == 6:
  646. if greenbutton8.isOver(pos):
  647. partics.append(Partic(70,90,100,100,white))
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654. if score == 6:
  655. if greenbutton9.isOver(pos):
  656. partics.append(Partic(190,90,100,100,white))
  657.  
  658.  
  659.  
  660.  
  661.  
  662. if score == 6:
  663. if greenbutton10.isOver(pos):
  664. partics.append(Partic(335,90,100,100,white))
  665.  
  666. #===================================================================================
  667.  
  668. #===================================================================================
  669.  
  670. if score == 7:
  671. if greenbutton2.isOver(pos):
  672. parts.append(Parti(190,215,100,100,white))
  673.  
  674.  
  675. if score == 7:
  676. if greenbutton3.isOver(pos):
  677. parts.append(Parti(335,215,100,100,white))
  678.  
  679.  
  680. if score == 7:
  681. if greenbutton4.isOver(pos):
  682. parts.append(Parti(71,215,100,100,white))
  683.  
  684.  
  685. if score == 7:
  686. if greenbutton5.isOver(pos):
  687. parts.append(Parti(71,350,100,100,white))
  688.  
  689. if score == 7:
  690. if greenbutton6.isOver(pos):
  691. parts.append(Parti(190,350,100,100,white))
  692.  
  693.  
  694. if score == 7:
  695. if greenbutton7.isOver(pos):
  696. parts.append(Parti(335,350,100,100,white))
  697.  
  698. if score == 7:
  699. if greenbutton8.isOver(pos):
  700. parts.append(Parti(70,90,100,100,white))
  701.  
  702. if score == 7:
  703. if greenbutton9.isOver(pos):
  704. parts.append(Parti(190,90,100,100,white))
  705.  
  706.  
  707. if score == 7:
  708. if greenbutton10.isOver(pos):
  709. parts.append(Parti(335,90,100,100,white))
  710.  
  711. # -------------------------------------------------------------------------------
  712. # -------------------------------------------------------------------------------
  713.  
  714. if score == 8:
  715. if greenbutton2.isOver(pos):
  716. partics.append(Partic(190,215,100,100,white))
  717.  
  718.  
  719. if score == 8:
  720. if greenbutton3.isOver(pos):
  721. partics.append(Partic(335,215,100,100,white))
  722.  
  723.  
  724.  
  725.  
  726.  
  727. if score == 8:
  728. if greenbutton4.isOver(pos):
  729. partics.append(Partic(71,215,100,100,white))
  730.  
  731.  
  732.  
  733.  
  734. if score == 8:
  735. if greenbutton5.isOver(pos):
  736. partics.append(Partic(71,350,100,100,white))
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743. if score == 8:
  744. if greenbutton6.isOver(pos):
  745. partics.append(Partic(190,350,100,100,white))
  746.  
  747.  
  748. if score == 8:
  749. if greenbutton7.isOver(pos):
  750. partics.append(Partic(335,350,100,100,white))
  751.  
  752.  
  753.  
  754. if score == 8:
  755. if greenbutton8.isOver(pos):
  756. partics.append(Partic(70,90,100,100,white))
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763. if score == 8:
  764. if greenbutton9.isOver(pos):
  765. partics.append(Partic(190,90,100,100,white))
  766.  
  767.  
  768.  
  769.  
  770.  
  771. if score == 8:
  772. if greenbutton10.isOver(pos):
  773. partics.append(Partic(335,90,100,100,white))
  774.  
  775. #===================================================================================
  776.  
  777.  
  778. #===================================================================================
  779.  
  780. if score == 9:
  781. if greenbutton2.isOver(pos):
  782. parts.append(Parti(190,215,100,100,white))
  783.  
  784.  
  785. if score == 9:
  786. if greenbutton3.isOver(pos):
  787. parts.append(Parti(335,215,100,100,white))
  788.  
  789.  
  790. if score == 9:
  791. if greenbutton4.isOver(pos):
  792. parts.append(Parti(71,215,100,100,white))
  793.  
  794.  
  795. if score == 9:
  796. if greenbutton5.isOver(pos):
  797. parts.append(Parti(71,350,100,100,white))
  798.  
  799. if score == 9:
  800. if greenbutton6.isOver(pos):
  801. parts.append(Parti(190,350,100,100,white))
  802.  
  803.  
  804. if score == 9:
  805. if greenbutton7.isOver(pos):
  806. parts.append(Parti(335,350,100,100,white))
  807.  
  808. if score == 9:
  809. if greenbutton8.isOver(pos):
  810. parts.append(Parti(70,90,100,100,white))
  811.  
  812. if score == 9:
  813. if greenbutton9.isOver(pos):
  814. parts.append(Parti(190,90,100,100,white))
  815.  
  816.  
  817. if score == 9:
  818. if greenbutton10.isOver(pos):
  819. parts.append(Parti(335,90,100,100,white))
  820.  
  821. # -------------------------------------------------------------------------------
  822.  
  823. # -------------------------------------------------------------------------------
  824.  
  825. if score == 10:
  826. if greenbutton2.isOver(pos):
  827. partics.append(Partic(190,215,100,100,white))
  828.  
  829.  
  830. if score == 10:
  831. if greenbutton3.isOver(pos):
  832. partics.append(Partic(335,215,100,100,white))
  833.  
  834.  
  835.  
  836.  
  837.  
  838. if score == 8:
  839. if greenbutton4.isOver(pos):
  840. partics.append(Partic(71,215,100,100,white))
  841.  
  842.  
  843.  
  844.  
  845. if score == 10:
  846. if greenbutton5.isOver(pos):
  847. partics.append(Partic(71,350,100,100,white))
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854. if score == 10:
  855. if greenbutton6.isOver(pos):
  856. partics.append(Partic(190,350,100,100,white))
  857.  
  858.  
  859. if score == 10:
  860. if greenbutton7.isOver(pos):
  861. partics.append(Partic(335,350,100,100,white))
  862.  
  863.  
  864.  
  865. if score == 10:
  866. if greenbutton8.isOver(pos):
  867. partics.append(Partic(70,90,100,100,white))
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874. if score == 10:
  875. if greenbutton9.isOver(pos):
  876. partics.append(Partic(190,90,100,100,white))
  877.  
  878.  
  879.  
  880.  
  881.  
  882. if score == 10:
  883. if greenbutton10.isOver(pos):
  884. partics.append(Partic(335,90,100,100,white))
  885.  
  886.  
  887.  
  888.  
  889. for line in lines:
  890. line.draw()
  891.  
  892.  
  893.  
  894.  
  895.  
  896. #===================================================================================
  897.  
  898.  
  899. # our main loop
  900. runninggame = True
  901. while runninggame:
  902. clock.tick(fps)
  903. for event in pygame.event.get():
  904. if event.type == pygame.QUIT:
  905. runninggame = False
  906.  
  907. if event.type == pygame.MOUSEBUTTONDOWN:
  908. pos = pygame.mouse.get_pos()
  909. if greenbutton2.isOver(pos) or greenbutton3.isOver(pos) or greenbutton4.isOver(pos) or greenbutton5.isOver(pos) or greenbutton6.isOver(pos) or greenbutton7.isOver(pos) or greenbutton8.isOver(pos) or greenbutton9.isOver(pos) or greenbutton10.isOver(pos):
  910. score += 1
  911. cointext = font.render("" + str(score), True, (255,255,255))
  912. coinrect.center = ((100,50))
  913. turns()
  914.  
  915.  
  916. player_wins, row = winner( greenbutton8, greenbutton9, greenbutton10,
  917. greenbutton4, greenbutton2, greenbutton3,
  918. greenbutton5, greenbutton6, greenbutton7 )
  919. if ( player_wins != None ):
  920. print( "Player "+ player_wins + " has won on " + row )
  921.  
  922.  
  923.  
  924.  
  925.  
  926. redraw()
  927.  
  928.  
  929. pygame.display.update()
  930.  
  931. pygame.quit()
  932.  
  933.  
  934.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement