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)
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 while True: money,pollution,trash = kernel.simulate(UIDlist,building_list,balance_sheet,money,pollution,trash) print('Money is: '+str(money)) print('Pollution is: '+ str(pollution)) print('Trash is: '+ str(trash)) if money <= 0 or pollution >= 100 or trash >= 100: print("Game over") break time.sleep(0.1)