start building skeleton WIP

This commit is contained in:
cecilkorik 2024-02-04 00:23:53 -05:00
parent c95f1dbc29
commit ed8c496856
9 changed files with 77 additions and 0 deletions

1
conf/README.md Normal file
View file

@ -0,0 +1 @@
game configuration goes here

2
conf/init.json Normal file
View file

@ -0,0 +1,2 @@
{
}

1
data/README.md Normal file
View file

@ -0,0 +1 @@
game data goes here

3
engine/__init__.py Normal file
View file

@ -0,0 +1,3 @@
import data
import config
import screen

29
engine/config.py Normal file
View file

@ -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')

17
engine/data.py Normal file
View file

@ -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()

21
engine/screen.py Normal file
View file

@ -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()

3
pyglet_demo.py Normal file
View file

@ -0,0 +1,3 @@
import pyglet
pyglet.window

0
requirements.txt Normal file
View file