def mainLoop(screen): frames = 0 frameTime = 1000 / 60 endLoop = 0 background = 150, 150, 150 black = 0, 0, 0 inputs = Input.Input() #shipMap = Map.Map() #scene = Scene.Scene(size, "scenes/scene1.txt") #dialog = Dialog.Dialog(size, "Dialogs/dialog1.txt") gameStart = True trigger = None changeScreen = False isTriggered = [0,0,0,0,0,0,0,0] # global vars while not endLoop: startFrame = pygame.time.get_ticks() # inputs inputs.updateEvents() if inputs.quit == True: endLoop = 1 if inputs.mouseRelX or inputs.mouseRelY: if currentType == 2 or currentType == 0: current.isHovered(inputs.getMousePos()) pass if inputs.mouseButtons[0]: if currentType == 0: current.onClick(inputs.mouseX) if currentType == 1: trigger = current.isBoxClicked(inputs.getMousePos()) if currentType == 2: trigger = current.getClickedRoom() if currentType == 3: trigger = 0 if inputs.trig: trigger = inputs.trigger if gameStart: print('intro') current = Dialog.Dialog2(size, "Dialogs/dialog_intro.txt") currentType = 3 currentIndex = 2 gameStart = False if trigger is not None: changeState = None current, currentType, currentIndex, changeScreen, changeState = triggerManager(trigger, current, currentType, currentIndex, isTriggered) if changeState is not None: isTriggered[changeState] = 1 trigger = None if changeScreen: screen.fill(black) pygame.display.flip() pygame.time.delay(500) changeScreen = False screen.fill(background) current.draw(screen) #shipMap.draw(screen) #dialog.draw(screen) pygame.display.flip() # manage framerate endFrame = pygame.time.get_ticks() loopTime = endFrame - startFrame if loopTime < frameTime: pygame.time.delay(frameTime - loopTime) frames += 1 totalTime = pygame.time.get_ticks() avgFramerate = frames / (float(totalTime) / 1000) print("Frames : " + str(frames)) print("Time Running : " + str(totalTime / 1000) + "s") print(avgFramerate)