import pygame from pygame.locals import * from Classes.System.Components.Window import Window from Classes.System.Components.InputHandler import InputHandler from Classes.System.Network.TCPClient import TCPClient from Classes.System.Utils.Path import PathUtil class App: __window:Window __running:bool = True __FPS = 60 __clock = pygame.time.Clock() __myFont:pygame.font __inputHandler: InputHandler __tcpClient: TCPClient def __init__(self, width:int=1920, height:int=1080, title:str="default title"): pygame.font.init() self.__myFont = pygame.font.SysFont('Comic Sans MS', 30) self.__window = Window(width=width, height=height, title=title) self.__inputHandler = InputHandler() self.selectedCard = None self.startGameLoop() self.onCleanup() def startGameLoop(self): while self.__running: self.__clock.tick(self.__FPS) self.__window.getScreen().fill((0,0,0)) # render world self.__window.drawWorld(self.__world) # event handler self.handleEvent(pygame.event.get()) # emits update to the game pygame.display.update() # handles incoming event queue def handleEvent(self, events): # TODO: fix bug that stacks cards when dragging them around try: for event in events: if event.type == pygame.QUIT: self.onCleanup() except: pass # sets the running state for the gameloop def setRunning(self, running:bool): self.__running = running # ensures the gameloop stops running and the pygame instance is stopped properly def onCleanup(self): self.__running = False pygame.quit()