Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | None | 0 0
  1. class Connect4:
  2.     def __init__(self, rowCount, colCount, circleSize, window):
  3.         self.margin = 0
  4.         self.rowCount = rowCount
  5.         self.colCount = colCount
  6.         self.circleSpacing = 2
  7.         self.width = (circleSize + self.circleSpacing * 2) * rowCount
  8.         self.height = (circleSize + self.circleSpacing * 2) * colCount
  9.         self.window = window
  10.         self.data = []
  11.         self.frame = Frame(window)
  12.         self.frame.pack()
  13.         self.messageSize = 15
  14.         self.diameter = circleSize
  15.         self.initialColor = 'white'
  16.         self.quitButton = Button(self.frame, text='Quit', command=self.quitGame)
  17.         self.quitButton.pack(side=LEFT)
  18.         self.draw = Canvas(self.frame, height=self.height, width=self.width)
  19.         self.draw.bind('<Button-1>', self.mouseInput)
  20.         self.draw.pack(padx = self.margin, pady = self.margin)
  21.         self.circles = []
  22.         self.colors = []
  23.         self.circleSpacing = 2
  24.  
  25.         y = 0
  26.         for row in range(self.rowCount):
  27.             circleRow = []
  28.             colorRow = []
  29.             x = 0
  30.             for col in range(self.colCount):
  31.                 circleRow += [self.draw.create_oval(
  32.                     x + self.circleSpacing,
  33.                     y + self.circleSpacing,
  34.                     x + self.diameter - self.circleSpacing,
  35.                     y + self.diameter - self.circleSpacing,
  36.                     fill=self.initialColor)]
  37.                 colorRow += [self.initialColor]
  38.                 x += self.diameter + self.circleSpacing * 2
  39.             self.circles += [circleRow]
  40.             self.colors += [colorRow]
  41.             y += self.diameter + self.circleSpacing * 2
  42.  
  43.         self.message = self.draw.create_text(self.messageSize, self.height-self.messageSize, text='starting ley game', anchor='w', font='Courier 24')
  44.         for row in range(self.colCount):
  45.             boardRow = []
  46.             for col in range(self.colCount):
  47.                 boardRow += [' ']
  48.             self.data += [boardRow]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement