d
This commit is contained in:
@@ -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
main.py
1
main.py
@@ -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)
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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 = {}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user