parent
commit
cf901c5793
7 changed files with 44 additions and 1 deletions
  1. +2
    -1
      ht.config
  2. +1
    -0
      main.py
  3. +20
    -0
      py/desktop.py
  4. +2
    -0
      py/desktop_Platform.py
  5. +1
    -0
      py/desktop_Window.py
  6. +17
    -0
      py/desktop_aux.py
  7. +1
    -0
      py/ht_Context.py

+ 2
- 1
ht.config View File

@@ -8,7 +8,8 @@ windowTitle = Прототип: Отель
windowWidth = 900 windowWidth = 900


[player] [player]
base = 25
base = 75
left = 50
texture = stub texture = stub
visible = true visible = true




+ 1
- 0
main.py View File

@@ -44,6 +44,7 @@ def process(c):
# Perform context dependent calls of desktop functions. # Perform context dependent calls of desktop functions.
# Similar to context functions, but no platform is returned. # Similar to context functions, but no platform is returned.
desktop_applyConfigInit(p) desktop_applyConfigInit(p)
desktop_createConfigPlayerSprites(p)
desktop_createConfigStaticSprites(p) desktop_createConfigStaticSprites(p)
desktop_loadConfigTextures(p) desktop_loadConfigTextures(p)
ctrl.registerCallback(process) ctrl.registerCallback(process)


+ 20
- 0
py/desktop.py View File

@@ -18,6 +18,26 @@ def desktop_applyConfigInit(p):
value = desktop_aux_convertValue(val) value = desktop_aux_convertValue(val)
p.ctrl.set(key, value) p.ctrl.set(key, value)


# Create player sprites
#
# Conditions:
# 1. Config textures has just been loaded
def desktop_createConfigPlayerSprites(p):
if (
p.c.recentField != "didLoadConfigTextures"
):
return

for key in p.c.cfgTree:
if (
key == "player"
):
sprite = desktop_aux_createPlayerSprite(p, key, p.c.cfgTree[key])
p.player = sprite
p.playerSprites.append(sprite)
# Report finish.
p.ctrl.set("didCreateConfigPlayerSprites", True)

# Create static sprites # Create static sprites
# #
# Conditions: # Conditions:


+ 2
- 0
py/desktop_Platform.py View File

@@ -4,6 +4,8 @@ class desktop_Platform:
def __init__(self): def __init__(self):
self.c = None self.c = None
self.ctrl = None self.ctrl = None
self.player = None
self.statics = {} self.statics = {}
self.playerSprites = arcade.SpriteList()
self.staticSprites = arcade.SpriteList() self.staticSprites = arcade.SpriteList()
self.textures = {} self.textures = {}

+ 1
- 0
py/desktop_Window.py View File

@@ -14,6 +14,7 @@ class desktop_Window(arcade.Window):
def on_draw(self): def on_draw(self):
arcade.start_render() arcade.start_render()
self.p.staticSprites.draw() self.p.staticSprites.draw()
self.p.playerSprites.draw()


def on_mouse_press(self, x, y, button, key_modifiers): def on_mouse_press(self, x, y, button, key_modifiers):
print("mouse press:", x, y) print("mouse press:", x, y)


+ 17
- 0
py/desktop_aux.py View File

@@ -23,6 +23,23 @@ def desktop_aux_convertValue(
# String. # String.
return value return value


def desktop_aux_createPlayerSprite(
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["base"])
# Visibility.
sp.visible = True if desc["visible"] == "true" else False

return sp

def desktop_aux_createStaticSprite( def desktop_aux_createStaticSprite(
p: desktop_Platform, p: desktop_Platform,
name: str, name: str,


+ 1
- 0
py/ht_Context.py View File

@@ -4,6 +4,7 @@ class ht_Context:
self.cfgDir = None self.cfgDir = None
self.cfgPath = None self.cfgPath = None
self.cfgTree = {} self.cfgTree = {}
self.didCreateConfigPlayerSprites = False
self.didCreateConfigStaticSprites = False self.didCreateConfigStaticSprites = False
self.didLaunch = False self.didLaunch = False
self.didLoadConfigTextures = False self.didLoadConfigTextures = False


Loading…
Cancel
Save