def main_loop():

    balance_sheet = file_io.load_balance('balance_sheet.csv')
    player = file_io.load(chosenplayer)
    #print (player)
    init = player[0]
    building_list = player[1]
    UIDlist = player[2]
    money, pollution, trash = init
    # print(init)
    #print(building_list)
    #print(UIDlist)
    frame = 0
    crashed = False
    gameDisplay.fill(white)
    while not crashed:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                crashed = True
            # print(event)

        button("Build", 150, 472, 100, 50, red, bright_red, quitgame)
        #button("Upgrade", 250, 472, 100, 50, red, bright_red, quitgame)
        value_bar(524, 460, 100, 20, money, 800, green, black, white, border_thickness=1)
        value_bar(524, 490, 100, 20, pollution, 800, green, black, white, border_thickness=1)
        value_bar(644, 460, 100, 20, trash, 800, green, black, white, border_thickness=1)
        drawMap(1)
        frame = frame + 1
        if frame == 60:  # Clock divider because threading is hard
            money, pollution, trash = kernel.simulate(
                UIDlist, building_list, balance_sheet, money, pollution, trash)
            if money <= 0 or pollution >= 100 or trash >= 100:
                print("Game over")
                break
            #print('Money is: '+str(money))
            # print('Pollution is: '+ str(pollution)).
            #print('Trash is: '+ str(trash))
            frame = 0
        # print(secondframe)
#        bar(150, 200, 100, 20, green,black,white,3, frame,'100/100')
        #print(frame)
        pygame.display.update()
        clock.tick(60)
def main_loop():

    balance_sheet = file_io.load_balance('balance_sheet.csv')
    player = file_io.load(chosenplayer)
    #print (player)
    init = player[0]
    building_list = player[1]
    UIDlist = player[2]
    money, pollution, trash = init
    # print(init)
    #print(building_list)
    #print(UIDlist)
    frame = 0
    crashed = False
    gameDisplay.fill(white)
    while not crashed:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                crashed = True
            # print(event)

        button("Build", 150, 472, 100, 50, red, bright_red, quitgame)
        #button("Upgrade", 250, 472, 100, 50, red, bright_red, quitgame)
        value_bar(524,
                  460,
                  100,
                  20,
                  money,
                  800,
                  green,
                  black,
                  white,
                  border_thickness=1)
        value_bar(524,
                  490,
                  100,
                  20,
                  pollution,
                  800,
                  green,
                  black,
                  white,
                  border_thickness=1)
        value_bar(644,
                  460,
                  100,
                  20,
                  trash,
                  800,
                  green,
                  black,
                  white,
                  border_thickness=1)
        drawMap(1)
        frame = frame + 1
        if frame == 60:  # Clock divider because threading is hard
            money, pollution, trash = kernel.simulate(UIDlist, building_list,
                                                      balance_sheet, money,
                                                      pollution, trash)
            if money <= 0 or pollution >= 100 or trash >= 100:
                print("Game over")
                break
            #print('Money is: '+str(money))
            # print('Pollution is: '+ str(pollution)).
            #print('Trash is: '+ str(trash))
            frame = 0
        # print(secondframe)


#        bar(150, 200, 100, 20, green,black,white,3, frame,'100/100')
#print(frame)
        pygame.display.update()
        clock.tick(60)
balance_sheet = {}
player_list = {}
building_list = {}
building_add = []
UIDlist = []
money = 10
pollution = 0
trash = 0
init = 0
asdf = 0
chosenplayer = "asdf"

# load balance sheet

balance_sheet = file_io.load_balance("balance_sheet.csv")

# load savefilev for testing

player = file_io.load(chosenplayer)
print(player)
init = player[0]
building_list = player[1]
UIDlist = player[2]
money, pollution, trash = init
# print(init)
# print(building_list)
# print(UIDlist)d

# test buildingctl.addbuilding - Add building
balance_sheet = {}
player_list = {}
building_list = {}
building_add = []
UIDlist = []
money = 10
pollution = 0
trash = 0
init = 0
asdf = 0
chosenplayer = 'asdf'

#load balance sheet

balance_sheet = file_io.load_balance('balance_sheet.csv')

#load savefilev for testing

player = file_io.load(chosenplayer)
print(player)
init = player[0]
building_list = player[1]
UIDlist = player[2]
money, pollution, trash = init
#print(init)
#print(building_list)
#print(UIDlist)d

#test buildingctl.addbuilding - Add building
Example #5
0
chosenplayer = 'asdf'


def clamp(n, minn, maxn):
    '''Keep values in between values
        Arguments:
        n: Value
        minn: Minimum value
        maxn: Maximum value
    '''
    return max(min(maxn, n), minn)

#load balance sheet

balance_sheet = file_io.load_balance('balance_sheet.csv')
#print(balance_sheet)

#load savefile

player = file_io.load(chosenplayer)
print (player)
init = player[0]
building_list = player[1]
UIDlist = player[2]
money,pollution,trash = init
#print(init)
print(building_list)
print(UIDlist)

#main loop