diff --git a/conf/README.md b/conf/README.md new file mode 100644 index 0000000..fb857fe --- /dev/null +++ b/conf/README.md @@ -0,0 +1 @@ +game configuration goes here \ No newline at end of file diff --git a/conf/init.json b/conf/init.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/conf/init.json @@ -0,0 +1,2 @@ +{ +} diff --git a/data/README.md b/data/README.md new file mode 100644 index 0000000..74a7c74 --- /dev/null +++ b/data/README.md @@ -0,0 +1 @@ +game data goes here \ No newline at end of file diff --git a/engine/__init__.py b/engine/__init__.py new file mode 100644 index 0000000..c316a1b --- /dev/null +++ b/engine/__init__.py @@ -0,0 +1,3 @@ +import data +import config +import screen \ No newline at end of file diff --git a/engine/config.py b/engine/config.py new file mode 100644 index 0000000..42c288d --- /dev/null +++ b/engine/config.py @@ -0,0 +1,29 @@ +import json +from collections import UserDict +import os +import sys +import data + +class SettingsLoader(UserDict): + def __init__(self: object, file: str) -> None: + self.data = {} + self.load_settings_file(file) + + def load_settings_file(self: object, file: str) -> None: + ext = os.path.splitext(file)[1] + with data.open('conf', file) as fd: + if ext == '.json': + self.data.extend(json.load(fd)) + else: + raise ValueError("Cannot open this type of settings file") + +class SettingsReadOnly(SettingsLoader): + pass + +class SettingsMutable(SettingsLoader): + pass + +class SettingsWritable(SettingsMutable): + pass + +init = SettingsWritable('init.json') diff --git a/engine/data.py b/engine/data.py new file mode 100644 index 0000000..dc5d226 --- /dev/null +++ b/engine/data.py @@ -0,0 +1,17 @@ +import os +import sys + +g_pp = None +def program_path() -> str: + global g_pp + + if g_pp == None: + g_pp = os.path.abspath(os.path.split(sys.argv[0])[0]) + + return g_pp + +def open(vault: str, path: str) -> object: + fp = os.path.join(program_path(), vault, path) + with open(fp, 'r') as fd: + return fd.read() + diff --git a/engine/screen.py b/engine/screen.py new file mode 100644 index 0000000..0d9e45e --- /dev/null +++ b/engine/screen.py @@ -0,0 +1,21 @@ +import pyglet +from . import config + +def auto_res(res) -> list: + return res + +def init_window() -> None: + res = [config.init.get('width'), config.init.get('height')] + fs = config.init.get('fullscreen') + borderless = config.init.get('borderless') + scaling = config.init.get('scaling') + + if fs and not borderless: + # real fullscreen mode is requested + # that means we need to carefully select + # an available resolution + pass + + + + pyglet.window.Window() \ No newline at end of file diff --git a/pyglet_demo.py b/pyglet_demo.py new file mode 100644 index 0000000..e1cfec7 --- /dev/null +++ b/pyglet_demo.py @@ -0,0 +1,3 @@ +import pyglet + +pyglet.window \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29