diff --git a/ht.config b/ht.config index 60bc259..d8837a8 100644 --- a/ht.config +++ b/ht.config @@ -8,7 +8,19 @@ windowWidth = 900 [static "s-floor1"] left = 0 texture = t-floor1 -top = 100 +top = 25 +visible = true + +[static "s-floor2"] +left = 0 +texture = t-floor1 +top = 225 +visible = true + +[static "s-floor3"] +left = 0 +texture = t-floor1 +top = 425 visible = true [texture "t-floor1"] diff --git a/py/cfg_aux.py b/py/cfg_aux.py index 8a6967c..bc50cf7 100644 --- a/py/cfg_aux.py +++ b/py/cfg_aux.py @@ -1,12 +1,22 @@ from cld import * +# Extract static sprite name from config section +def cfg_aux_staticSpriteName( + sectionName: str +) -> str: + prefix = f"static \"" + postfix = f"\"" + start = cld_len(prefix) + end = cld_len(postfix) + return sectionName[start:-end] + # Extract texture name from config section def cfg_aux_textureName( sectionName: str ) -> str: - prefix = "texture \"" - postfix = "\"" - start = cld_len(prefix) + 1 + prefix = f"texture \"" + postfix = f"\"" + start = cld_len(prefix) end = cld_len(postfix) return sectionName[start:-end] diff --git a/py/cfg_aux_test.py b/py/cfg_aux_test.py index d7cfa7c..653a6bd 100644 --- a/py/cfg_aux_test.py +++ b/py/cfg_aux_test.py @@ -1,8 +1,18 @@ from cfg_aux import * +def test_cfg_aux_staticSpriteName( +) -> str: + section = f"static \"s-floor1\"" + name = cfg_aux_staticSpriteName(section) + if ( + name == "s-floor1" + ): + return "OK: cfg_aux_staticSpriteName" + return "ERR: cfg_aux_staticSpriteName" + def test_cfg_aux_textureName( ) -> str: - section = "textures \"t-floor1\"" + section = f"texture \"t-floor1\"" tex = cfg_aux_textureName(section) if ( tex == "t-floor1" diff --git a/py/desktop.py b/py/desktop.py index a51f459..ebb5126 100644 --- a/py/desktop.py +++ b/py/desktop.py @@ -32,9 +32,10 @@ def desktop_createConfigStaticSprites(p): if ( cld_startswith(key, "static ") ): - name = cfg_aux_spriteName(key) - sprite = desktop_aux_createSprite(p.c.cfgTree[key]) + name = cfg_aux_staticSpriteName(key) + sprite = desktop_aux_createStaticSprite(p, name, p.c.cfgTree[key]) p.statics[name] = sprite + p.staticSprites.append(sprite) # Report finish. p.ctrl.set("didCreateConfigStaticSprites", True) diff --git a/py/desktop_aux.py b/py/desktop_aux.py index 37e3b64..3ea94aa 100644 --- a/py/desktop_aux.py +++ b/py/desktop_aux.py @@ -1,5 +1,6 @@ import arcade from cld import * +from desktop_Platform import * # Convert String config value to Bool or Float if possible def desktop_aux_convertValue( @@ -22,7 +23,23 @@ def desktop_aux_convertValue( # String. return value -# Load texture +def desktop_aux_createStaticSprite( + p: desktop_Platform, + name: str, + desc: dict[str, str] +): + sp = arcade.Sprite() + sp.guid = name + texName = desc["texture"] + sp.texture = p.textures[texName] + # Position. + sp.left = float(desc["left"]) + sp.top = float(desc["top"]) + # Visibility. + sp.visible = True if desc["visible"] == "true" else False + + return sp + def desktop_aux_loadTexture( resDir: str, desc: dict[str, str] diff --git a/py/do-test.py b/py/do-test.py index d5dc662..2faac0f 100755 --- a/py/do-test.py +++ b/py/do-test.py @@ -11,6 +11,7 @@ from cfg_test import * functions = [ test_cfg_parseConfigTree, + test_cfg_aux_staticSpriteName, test_cfg_aux_textureName, test_cfg_aux_tree, test_cfg_aux_treeCreateSection,