d
This commit is contained in:
@@ -1,21 +1,6 @@
|
|||||||
import arcade
|
import arcade
|
||||||
from desktop_Platform import *
|
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):
|
def desktop_createDeselectedTiles(p):
|
||||||
for (id, pos) in enumerate(p.c.tilePositions):
|
for (id, pos) in enumerate(p.c.tilePositions):
|
||||||
tile = arcade.AnimatedTimeBasedSprite()
|
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
|
# Hide deselected tile and show selected one
|
||||||
#
|
#
|
||||||
# Conditions:
|
# Conditions:
|
||||||
@@ -73,13 +73,40 @@ def desktop_hideMatchingTiles(p):
|
|||||||
if (
|
if (
|
||||||
p.c.recentField == "hideMatchingTiles"
|
p.c.recentField == "hideMatchingTiles"
|
||||||
):
|
):
|
||||||
for id in p.c.hiddenItems:
|
for id in p.c.selectedItems:
|
||||||
p.deselectedTiles[id].visible = False
|
p.deselectedTiles[id].visible = False
|
||||||
p.selectedTiles[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
|
# Postpone hiding of matching tiles for better UX
|
||||||
#
|
#
|
||||||
# Conditions:
|
# Conditions:
|
||||||
|
|||||||
@@ -85,19 +85,24 @@ p.ctrl = ctrl
|
|||||||
p.sequentialTimer = desktop_SequentialTimer()
|
p.sequentialTimer = desktop_SequentialTimer()
|
||||||
p.sequentialTimer.callback = lambda key, value: ctrl.set(key, value)
|
p.sequentialTimer.callback = lambda key, value: ctrl.set(key, value)
|
||||||
|
|
||||||
# Copy context to platform.
|
# Bind platform to context changes.
|
||||||
# And process lots of functions that are interested in changes.
|
|
||||||
def process(c):
|
def process(c):
|
||||||
|
# Copy context to platform.
|
||||||
p.c = c
|
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_displaySelectedTile(p)
|
||||||
desktop_hideMatchingTiles(p)
|
desktop_hideMatchingTiles(p)
|
||||||
desktop_scheduleHidingOfMatchingTiles(p)
|
desktop_scheduleHidingOfMatchingTiles(p)
|
||||||
|
desktop_scheduleDeselectionOfMismatchedTiles(p)
|
||||||
ctrl.registerCallback(process)
|
ctrl.registerCallback(process)
|
||||||
|
|
||||||
ctrl.set("didLaunch", True)
|
ctrl.set("didLaunch", True)
|
||||||
ctrl.set("playfieldSize", 2)
|
ctrl.set("playfieldSize", 2)
|
||||||
|
|
||||||
ctrl.set("cellSize", 25)
|
ctrl.set("cellSize", 25)
|
||||||
|
ctrl.set("deselectMismatchedTilesDelay", 500)
|
||||||
ctrl.set("hideMatchingTilesDelay", 500)
|
ctrl.set("hideMatchingTilesDelay", 500)
|
||||||
ctrl.set("tileImage", "res/tiles.png")
|
ctrl.set("tileImage", "res/tiles.png")
|
||||||
ctrl.set("tileImageCount", 3)
|
ctrl.set("tileImageCount", 3)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
class memory_Context:
|
class memory_Context:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cellSize = 0
|
self.cellSize = 0
|
||||||
|
self.deselectMismatchedTiles = False
|
||||||
|
self.deselectMismatchedTilesDelay = 0
|
||||||
self.didLaunch = False
|
self.didLaunch = False
|
||||||
self.exit = False
|
self.exit = False
|
||||||
self.hiddenItems = []
|
self.hiddenItems = []
|
||||||
|
|||||||
Reference in New Issue
Block a user