d
This commit is contained in:
@@ -50,3 +50,45 @@ def desktop_createSelectedTiles(p):
|
|||||||
tile.visible = False
|
tile.visible = False
|
||||||
#}
|
#}
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
# Hide deselected tile and show selected one
|
||||||
|
#
|
||||||
|
# Conditions:
|
||||||
|
# 1. tile has just been selected
|
||||||
|
def desktop_displaySelectedTile(p):
|
||||||
|
if (
|
||||||
|
p.c.recentField == "selectedId"
|
||||||
|
):
|
||||||
|
id = p.c.selectedId
|
||||||
|
p.deselectedTiles[id].visible = False
|
||||||
|
p.selectedTiles[id].visible = True
|
||||||
|
#}
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Postpone hiding of matching tiles for better UX
|
||||||
|
#
|
||||||
|
# Conditions:
|
||||||
|
# 1. a pair of tiles has been matched
|
||||||
|
def desktop_scheduleHidingOfMatchingTiles(p):
|
||||||
|
if (
|
||||||
|
p.c.recentField == "hiddenItems"
|
||||||
|
):
|
||||||
|
p.sequentialTimer.schedule("hideMatchingTiles", True, 500)
|
||||||
|
#}
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Hide matching tiles
|
||||||
|
# TODO: Rearrange the position of the func
|
||||||
|
#
|
||||||
|
# Conditions:
|
||||||
|
# 1. ...
|
||||||
|
#def desktop_hideMatchingTiles(p):
|
||||||
|
# if (
|
||||||
|
# p.c.recentField == "hiddenItems"
|
||||||
|
# ):
|
||||||
|
# for id in p.c.hiddenItems:
|
||||||
|
# p.deselectedTiles[id].visible = False
|
||||||
|
# p.selectedTiles[id].visible = False
|
||||||
|
# #}
|
||||||
|
# #}
|
||||||
|
##}
|
||||||
|
|||||||
@@ -7,5 +7,6 @@ class desktop_Platform:
|
|||||||
self.deselectedTiles = []
|
self.deselectedTiles = []
|
||||||
self.mousePosition = []
|
self.mousePosition = []
|
||||||
self.selectedTiles = []
|
self.selectedTiles = []
|
||||||
|
self.sequentialTimer = None
|
||||||
self.sprites = arcade.SpriteList()
|
self.sprites = arcade.SpriteList()
|
||||||
self.textures = []
|
self.textures = []
|
||||||
|
|||||||
10
v5/desktop_SequentialTimer.py
Normal file
10
v5/desktop_SequentialTimer.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class desktop_SequentialTimer():
|
||||||
|
def __init__(self):
|
||||||
|
self.queue = []
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def schedule(self, key, value, timeout):
|
||||||
|
pass
|
||||||
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import arcade
|
import arcade
|
||||||
|
|
||||||
# Find tile id at the specified location
|
# Find a visible tile id at the specified location
|
||||||
def desktop_aux_tileIdAt(p, x, y):
|
def desktop_aux_tileIdAt(p, x, y):
|
||||||
sprites = arcade.get_sprites_at_point([x, y], p.sprites)
|
sprites = arcade.get_sprites_at_point([x, y], p.sprites)
|
||||||
if (
|
if (
|
||||||
len(sprites) != 0
|
len(sprites) != 0 and
|
||||||
|
sprites[0].visible
|
||||||
):
|
):
|
||||||
return sprites[0].guid
|
return sprites[0].guid
|
||||||
#}
|
#}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from ctx import *
|
|||||||
from ctx_test2 import *
|
from ctx_test2 import *
|
||||||
from desktop import *
|
from desktop import *
|
||||||
from desktop_Platform import *
|
from desktop_Platform import *
|
||||||
|
from desktop_SequentialTimer import *
|
||||||
from desktop_Window import *
|
from desktop_Window import *
|
||||||
from gui import *
|
from gui import *
|
||||||
from gui_aux_test import *
|
from gui_aux_test import *
|
||||||
@@ -81,13 +82,16 @@ ctrl.registerCallback(printOutput)
|
|||||||
ctrl.registerFieldCallback("exit", lambda c: sys.exit(0))
|
ctrl.registerFieldCallback("exit", lambda c: sys.exit(0))
|
||||||
|
|
||||||
p = desktop_Platform()
|
p = desktop_Platform()
|
||||||
# Keep copy of ctrl in platform, too.
|
|
||||||
p.ctrl = ctrl
|
p.ctrl = ctrl
|
||||||
|
p.sequentialTimer = desktop_SequentialTimer()
|
||||||
|
|
||||||
# Copy context to platform.
|
# Copy context to platform.
|
||||||
def copyContext(c):
|
# And process lots of functions that are interested in changes.
|
||||||
|
def process(c):
|
||||||
p.c = c
|
p.c = c
|
||||||
ctrl.registerCallback(copyContext)
|
desktop_displaySelectedTile(p)
|
||||||
|
desktop_scheduleHidingOfMatchingTiles(p)
|
||||||
|
ctrl.registerCallback(process)
|
||||||
|
|
||||||
ctrl.set("didLaunch", True)
|
ctrl.set("didLaunch", True)
|
||||||
ctrl.set("playfieldSize", 2)
|
ctrl.set("playfieldSize", 2)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class memory_Context:
|
|||||||
self.didLaunch = False
|
self.didLaunch = False
|
||||||
self.exit = False
|
self.exit = False
|
||||||
self.hiddenItems = []
|
self.hiddenItems = []
|
||||||
|
self.hideMatchingTiles = False
|
||||||
self.input = ""
|
self.input = ""
|
||||||
self.mismatchedItems = []
|
self.mismatchedItems = []
|
||||||
self.outputGoOn = ""
|
self.outputGoOn = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user