def run(self): while True: for event in pygame.event.get(): # User did something if event.type == pygame.QUIT: # If user clicked close sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: self.mouse = self.getMousePos() print self.mouse if not self.isHighLighted: for p in self.g.pieces: if p.col == self.mouse[1] and p.row == self.mouse[0]: self.isHighLighted = True self.mouse = (self.mouse[0],self.mouse[1]) self.piece = p break else: movingAlgo.manualMove(self.piece,self.g.WPieces,self.g.BPieces,self.mouse[1],self.mouse[0]) self.isHighLighted = False self.clock.tick(60) self.screen.fill(self.LGREY) self.draw() pygame.display.flip()
def createBlackP(self): blackList = [] while True: randCol = self.getRndmNum() randRow = self.getRndmNum() p = King(randCol,randRow,1) if movingAlgo.manualMove(p,self.WPieces,self.BPieces,randCol,randRow): blackList.append(p) break else: continue return blackList