Михаил Капелько 6 days ago
parent
commit
574cc65c59
6 changed files with 64 additions and 5 deletions
  1. +42
    -0
      v5/desktop.py
  2. +1
    -0
      v5/desktop_Platform.py
  3. +10
    -0
      v5/desktop_SequentialTimer.py
  4. +3
    -2
      v5/desktop_aux.py
  5. +7
    -3
      v5/main-gui.py
  6. +1
    -0
      v5/memory_Context.py

+ 42
- 0
v5/desktop.py View File

@@ -50,3 +50,45 @@ def desktop_createSelectedTiles(p):
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
# #}
# #}
##}

+ 1
- 0
v5/desktop_Platform.py View File

@@ -7,5 +7,6 @@ class desktop_Platform:
self.deselectedTiles = []
self.mousePosition = []
self.selectedTiles = []
self.sequentialTimer = None
self.sprites = arcade.SpriteList()
self.textures = []

+ 10
- 0
v5/desktop_SequentialTimer.py View File

@@ -0,0 +1,10 @@
class desktop_SequentialTimer():
def __init__(self):
self.queue = []

def update(self):
pass

def schedule(self, key, value, timeout):
pass

+ 3
- 2
v5/desktop_aux.py View File

@@ -1,10 +1,11 @@
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):
sprites = arcade.get_sprites_at_point([x, y], p.sprites)
if (
len(sprites) != 0
len(sprites) != 0 and
sprites[0].visible
):
return sprites[0].guid
#}


+ 7
- 3
v5/main-gui.py View File

@@ -5,6 +5,7 @@ from ctx import *
from ctx_test2 import *
from desktop import *
from desktop_Platform import *
from desktop_SequentialTimer import *
from desktop_Window import *
from gui import *
from gui_aux_test import *
@@ -81,13 +82,16 @@ ctrl.registerCallback(printOutput)
ctrl.registerFieldCallback("exit", lambda c: sys.exit(0))

p = desktop_Platform()
# Keep copy of ctrl in platform, too.
p.ctrl = ctrl
p.sequentialTimer = desktop_SequentialTimer()

# Copy context to platform.
def copyContext(c):
# And process lots of functions that are interested in changes.
def process(c):
p.c = c
ctrl.registerCallback(copyContext)
desktop_displaySelectedTile(p)
desktop_scheduleHidingOfMatchingTiles(p)
ctrl.registerCallback(process)

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


+ 1
- 0
v5/memory_Context.py View File

@@ -4,6 +4,7 @@ class memory_Context:
self.didLaunch = False
self.exit = False
self.hiddenItems = []
self.hideMatchingTiles = False
self.input = ""
self.mismatchedItems = []
self.outputGoOn = ""


Loading…
Cancel
Save