def __init__(self): os.environ['SDL_VIDEO_CENTERED'] = '1' pygame.init() self.running = True self.screen = pygame.display.set_mode((WIDTH, HEIGHT + TILE_SIZE + 20)) self.clock = pygame.time.Clock() #---------------------------------------------------------------------------------------# self.stateDict = { "MENU": Menu(), "PATHFINDING": PathFinding(), "ABOUT": About() } self.loadState("MENU")
WIDTH = 600 HEIGHT = 400 pygame.mixer.init() pygame.font.init() pygame.display.set_caption('Pong') from states import Menu #https://www.dl-sounds.com/royalty-free/off-limits/ pygame.mixer.music.load('assets/Off_Limits.wav') pygame.mixer.music.play(loops=-1) screen = pygame.display.set_mode((WIDTH, HEIGHT)) surface = pygame.display.get_surface() state = Menu(WIDTH, HEIGHT) keys_pressed = set() done = False last = 0 while not done: # delay until 1/60th of second while time.time() - last < 1 / 60: pass last = time.time() # pump events for event in pygame.event.get(): if event.type == pygame.QUIT: done = True if event.type == pygame.KEYDOWN: