Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Connect4:
- def __init__(self, rowCount, colCount, circleSize, window):
- self.margin = 0
- self.rowCount = rowCount
- self.colCount = colCount
- self.circleSpacing = 2
- self.width = (circleSize + self.circleSpacing * 2) * rowCount
- self.height = (circleSize + self.circleSpacing * 2) * colCount
- self.window = window
- self.data = []
- self.frame = Frame(window)
- self.frame.pack()
- self.messageSize = 15
- self.diameter = circleSize
- self.initialColor = 'white'
- self.quitButton = Button(self.frame, text='Quit', command=self.quitGame)
- self.quitButton.pack(side=LEFT)
- self.draw = Canvas(self.frame, height=self.height, width=self.width)
- self.draw.bind('<Button-1>', self.mouseInput)
- self.draw.pack(padx = self.margin, pady = self.margin)
- self.circles = []
- self.colors = []
- self.circleSpacing = 2
- y = 0
- for row in range(self.rowCount):
- circleRow = []
- colorRow = []
- x = 0
- for col in range(self.colCount):
- circleRow += [self.draw.create_oval(
- x + self.circleSpacing,
- y + self.circleSpacing,
- x + self.diameter - self.circleSpacing,
- y + self.diameter - self.circleSpacing,
- fill=self.initialColor)]
- colorRow += [self.initialColor]
- x += self.diameter + self.circleSpacing * 2
- self.circles += [circleRow]
- self.colors += [colorRow]
- y += self.diameter + self.circleSpacing * 2
- self.message = self.draw.create_text(self.messageSize, self.height-self.messageSize, text='starting ley game', anchor='w', font='Courier 24')
- for row in range(self.colCount):
- boardRow = []
- for col in range(self.colCount):
- boardRow += [' ']
- self.data += [boardRow]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement