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() p.deselectedTiles.append(tile) p.sprites.append(tile) tile.guid = id tile.texture = p.textures[0] # Animation between two textures. a1 = arcade.sprite.AnimationKeyframe(0, 700, p.textures[0]) a2 = arcade.sprite.AnimationKeyframe(1, 700, p.textures[1]) tile.frames.append(a1) tile.frames.append(a2) # Position. tile.left = pos[0] tile.top = pos[1] #} #} def desktop_createSelectedTiles(p): for (id, pos) in enumerate(p.c.tilePositions): tile = arcade.Sprite() p.selectedTiles.append(tile) p.sprites.append(tile) tile.guid = id tile.texture = p.textures[2] # Position. tile.left = pos[0] tile.top = pos[1] # Invisible by default. 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 #} #} # Hide matching tiles # # Conditions: # 1. Time to hide matching items def desktop_hideMatchingTiles(p): if ( p.c.recentField == "hideMatchingTiles" ): for id in p.c.hiddenItems: p.deselectedTiles[id].visible = False p.selectedTiles[id].visible = False #} #} #} # 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, p.c.hideMatchingTilesDelay) #} #}