Exemple #1
0
if __name__ == "__main__":
    plays = {}  #storing the number of plays

    #connect the backend with frontend
    pygame.init()
    screen_width = 500
    screen_height = 500
    startObj = Draw(screen_width, screen_height)

    while True:
        startObj.start_loop()
        print("\nPlayer #{}:\n".format(len(plays) + 1))

        while startObj.getStart():  #Catch any input error from the user's size
            pygame.time.wait(200)  #delay to avoid choosing the grip mistakenly
            startObj.chooseGridSize()

            try:
                print "size: ",
                size = startObj.getGridSize()
                print size
            except ValueError as VE:
                print("{}\n".format(VE))
            else:
                if size < 3 or size > 9:
                    print("\nThe size between (3, 9)\n")
                    continue
                break

        obj = Main(size)
        plays[obj] = obj.createGame()  #creating new object with required size