From 124719c0f9258a0aa2ec0cebc1928fa97ecb3a0b Mon Sep 17 00:00:00 2001 From: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:36:26 +0100 Subject: [PATCH] first config file first 60 fps purple screen created, size depends on config --- config.json | 7 +++++++ main.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 config.json create mode 100644 main.py diff --git a/config.json b/config.json new file mode 100644 index 0000000..ddb4598 --- /dev/null +++ b/config.json @@ -0,0 +1,7 @@ +{ + "screen": + { + "res":[1120, 780], + "fullscreen": false + } +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..c7290d0 --- /dev/null +++ b/main.py @@ -0,0 +1,41 @@ +import pygame +import sys +import json +import time + +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() + running = True + return screen, clock, running + +def readConfig(): + with open('config.json', 'r') as c: + json_data = c.read() + return json.loads(json_data) + +def main(): + config = readConfig() + screen, clock, running = setUp(config["screen"]) + while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + # fill the screen with a color to wipe away anything from last frame + screen.fill("purple") + + # RENDER YOUR GAME HERE + + # 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()