def main(self): # load big resources first cardPath = os.path.join(os.getcwd(), "res", "cardData.json") allCardData = None with open(cardPath, 'r', encoding="utf-8") as f: allCardData = json.load(f) # SET UP THE GRAPHICS WINDOW window = sf.RenderWindow(sf.VideoMode(1100, 800), 'Mana Burn') window.framerate_limit = 60 window.clear() view = sf.View() view.reset(sf.Rectangle((0, 0), (1100, 850))) window.view = view window.display() # figure out the save game situation currentSavedGame = SavedGame() currentScreen = MainScreen(window, view, currentSavedGame, allCardData) # A clock runs and cleans up dead objects periodically cleanupClock = sf.Clock() # THE UPDATE AND GAME LOOP while window.is_open: for event in window.events: if type(event) is sf.CloseEvent: window.close() if type(event ) is sf.KeyEvent and event.code is sf.Keyboard.ESCAPE: window.close() if type(currentScreen) is MainScreen: if type(event) is sf.MouseButtonEvent: currentScreen.checkClicks(window, event) if type(event) is sf.MouseWheelEvent: currentScreen.checkScroll(window, event) window.clear() currentScreen.update() window.display() if cleanupClock.elapsed_time.seconds >= .5: currentScreen.cleanUp() cleanupClock.restart()