Михаил Капелько hace 5 meses
padre
commit
4f5f16fc75
Se han modificado 3 ficheros con 52 adiciones y 18 borrados
  1. +43
    -16
      v5/desktop.py
  2. +7
    -2
      v5/main-gui.py
  3. +2
    -0
      v5/memory_Context.py

+ 43
- 16
v5/desktop.py Ver fichero

@@ -1,21 +1,6 @@
import arcade
from desktop_Platform import *

def desktop_loadTextures(p):
texs = []
for (id, td) in enumerate(p.c.textureDescriptions):
tex = arcade.load_texture(
td.fileName,
x = td.x,
y = td.y,
width = td.width,
height = td.height
)
texs.append(tex)
#}
p.textures = texs
#}

def desktop_createDeselectedTiles(p):
for (id, pos) in enumerate(p.c.tilePositions):
tile = arcade.AnimatedTimeBasedSprite()
@@ -51,6 +36,21 @@ def desktop_createSelectedTiles(p):
#}
#}

# Deselect mismatched tiles
#
# Conditions:
# 1. Time to deselect mismatched items
def desktop_deselectMismatchedTiles(p):
if (
p.c.recentField == "deselectMismatchedTiles"
):
for id in p.c.mismatchedItems:
p.deselectedTiles[id].visible = True
p.selectedTiles[id].visible = False
#}
#}
#}

# Hide deselected tile and show selected one
#
# Conditions:
@@ -73,13 +73,40 @@ def desktop_hideMatchingTiles(p):
if (
p.c.recentField == "hideMatchingTiles"
):
for id in p.c.hiddenItems:
for id in p.c.selectedItems:
p.deselectedTiles[id].visible = False
p.selectedTiles[id].visible = False
#}
#}
#}

def desktop_loadTextures(p):
texs = []
for (id, td) in enumerate(p.c.textureDescriptions):
tex = arcade.load_texture(
td.fileName,
x = td.x,
y = td.y,
width = td.width,
height = td.height
)
texs.append(tex)
#}
p.textures = texs
#}

# Postpone deselection of mismatched tiles for better UX
#
# Conditions:
# 1. a pair of tiles has been mismatched
def desktop_scheduleDeselectionOfMismatchedTiles(p):
if (
p.c.recentField == "mismatchedItems"
):
p.sequentialTimer.schedule("deselectMismatchedTiles", True, p.c.deselectMismatchedTilesDelay)
#}
#}

# Postpone hiding of matching tiles for better UX
#
# Conditions:


+ 7
- 2
v5/main-gui.py Ver fichero

@@ -85,19 +85,24 @@ p.ctrl = ctrl
p.sequentialTimer = desktop_SequentialTimer()
p.sequentialTimer.callback = lambda key, value: ctrl.set(key, value)

# Copy context to platform.
# And process lots of functions that are interested in changes.
# Bind platform to context changes.
def process(c):
# Copy context to platform.
p.c = c
# Perform context dependent calls of desktop functions.
# Similar to context functions, but no platform is returned.
desktop_deselectMismatchedTiles(p)
desktop_displaySelectedTile(p)
desktop_hideMatchingTiles(p)
desktop_scheduleHidingOfMatchingTiles(p)
desktop_scheduleDeselectionOfMismatchedTiles(p)
ctrl.registerCallback(process)

ctrl.set("didLaunch", True)
ctrl.set("playfieldSize", 2)

ctrl.set("cellSize", 25)
ctrl.set("deselectMismatchedTilesDelay", 500)
ctrl.set("hideMatchingTilesDelay", 500)
ctrl.set("tileImage", "res/tiles.png")
ctrl.set("tileImageCount", 3)


+ 2
- 0
v5/memory_Context.py Ver fichero

@@ -1,6 +1,8 @@
class memory_Context:
def __init__(self):
self.cellSize = 0
self.deselectMismatchedTiles = False
self.deselectMismatchedTilesDelay = 0
self.didLaunch = False
self.exit = False
self.hiddenItems = []


Cargando…
Cancelar
Guardar