From 5e33e553968ea2064e33cde7ba8b59b05cd257aa Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Thu, 2 Apr 2020 15:50:47 +0200 Subject: [PATCH] initialized pygame --- data/config/mainConfig.json | 6 ++++++ src/game/Game.py | 30 ++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/data/config/mainConfig.json b/data/config/mainConfig.json index e69de29..8fa6c30 100644 --- a/data/config/mainConfig.json +++ b/data/config/mainConfig.json @@ -0,0 +1,6 @@ +{ + "window": { + "width": 1280, + "height": 720 + } +} \ No newline at end of file diff --git a/src/game/Game.py b/src/game/Game.py index a783f92..dbd964b 100644 --- a/src/game/Game.py +++ b/src/game/Game.py @@ -1,6 +1,28 @@ +import pygame +import json +from pathlib import Path + + class Game: def __init__(self): - self.resolution - self.windowName - self.fps - self.timer + print("Loading configuration...", end=" ") + + try: + configFolder = Path("../../data/config/") + configFile = configFolder / "mainConfig.json" + + self.config = json.loads(configFile.read_text()) + + print("OK") + except IOError: + print("Error reading configuration file. Exiting...") + exit(1) + + print("Initializing pygame...", end=" ") + pygame.init() + print("OK") + + print("Initializing screen, params: " + str(self.config["window"]) + "...", end=" ") + + +game = Game()