import pygame import sys import json import time from classes import * def setUp(config): pygame.init() if config["fullscreen"]: screen = pygame.display.set_mode(config["res"], pygame.FULLSCREEN) else: screen = pygame.display.set_mode(config["res"]) clock = pygame.time.Clock() return screen, clock, True, True, "start.png", [] def readConfig(): with open('config.json', 'r') as c: json_data = c.read() return json.loads(json_data) def quitGame(): #save progress somehow, if needed pygame.quit() sys.exit() def uwu(): print('uwu') def main(): config = readConfig() screen, clock, running, isblack, background, objects = setUp(config["screen"]) WIDTH, HEIGHT = screen.get_size() objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', "Exit game", quitGame)) objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', "Options", uwu)) objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', "Play", uwu)) print(objects) while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if not isblack: with open(background, 'r') as i: bg = pygame.image.load(i) bg = pygame.transform.scale(bg, (WIDTH, HEIGHT)) # fill the screen with a color to wipe away anything from last frame screen.blit(bg, (0, 0)) # RENDER YOUR GAME HERE else: screen.fill('#000000') for obj in objects: obj.process(screen) # flip() the display to put your work on screen pygame.display.flip() clock.tick(60) # limits FPS to 60 pygame.quit() if __name__ == '__main__': main()