Parent
révision
cf901c5793
7 fichiers modifiés avec 44 ajouts et 1 suppressions
  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 Voir le fichier

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

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



+ 1
- 0
main.py Voir le fichier

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


+ 20
- 0
py/desktop.py Voir le fichier

@@ -18,6 +18,26 @@ def desktop_applyConfigInit(p):
value = desktop_aux_convertValue(val)
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
#
# Conditions:


+ 2
- 0
py/desktop_Platform.py Voir le fichier

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

+ 1
- 0
py/desktop_Window.py Voir le fichier

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

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


+ 17
- 0
py/desktop_aux.py Voir le fichier

@@ -23,6 +23,23 @@ def desktop_aux_convertValue(
# String.
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(
p: desktop_Platform,
name: str,


+ 1
- 0
py/ht_Context.py Voir le fichier

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


Chargement…
Annuler
Enregistrer