import arcade from gui_aux import * from desktop_Platform import * def desktop_createDesc(p): p.desc = arcade.Sprite() p.descSprites.append(p.desc) p.desc.texture = p.descTextures[0] # Position. pos = gui_aux_cellScreenPosition(p.c, p.c.descPosition) p.desc.left = pos[0] p.desc.top = pos[1] # Invisible by default. p.desc.visible = False #} def desktop_createDeselectedTiles(p): for (id, pos) in enumerate(p.c.tilePositions): tile = arcade.AnimatedTimeBasedSprite() p.deselectedTiles.append(tile) p.deselectedSprites.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.selectedSprites.append(tile) tile.guid = id tile.texture = p.textures[2 + p.c.playfieldItems[id]] # Position. tile.left = pos[0] tile.top = pos[1] # Invisible by default. tile.visible = False #} #} def desktop_createSplash(p): p.splash = arcade.Sprite() p.splashSprites.append(p.splash) p.splash.texture = p.splashTextures[0] # Position. pos = gui_aux_cellScreenPosition(p.c, [0, 0]) p.splash.left = pos[0] p.splash.top = pos[1] #} def desktop_createTitle(p): p.title = arcade.Sprite() p.titleSprites.append(p.title) p.title.texture = p.titleTextures[0] # Position. pos = gui_aux_cellScreenPosition(p.c, p.c.titlePosition) p.title.left = pos[0] p.title.top = pos[1] # Invisible by default. p.title.visible = False #} # 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 #} #} #} # Display description for the first selected tile # # Conditions: # 1. tile has just been selected and it's the first one in pair def desktop_displayDesc(p): if ( p.c.recentField == "selectedId" and ( len(p.c.selectedItems) == 0 or len(p.c.selectedItems) == 2 ) ): gid = p.c.playfieldItems[p.c.selectedId] p.desc.texture = p.descTextures[gid] p.desc.visible = True #} #} # Display ending splash screen # # Conditions: # 1. Time to display victory screen def desktop_displayEndingSplashScreen(p): if ( p.c.recentField == "displayEndingSplashScreen" ): p.splash.texture = p.splashTextures[1] p.splash.visible = True #} #} # 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 #} #} # Display title for the first selected tile # # Conditions: # 1. tile has just been selected and it's the first one in pair def desktop_displayTitle(p): if ( p.c.recentField == "selectedId" and ( len(p.c.selectedItems) == 0 or len(p.c.selectedItems) == 2 ) ): gid = p.c.playfieldItems[p.c.selectedId] p.title.texture = p.titleTextures[gid] p.title.visible = True #} #} # Hide beginning splash screen # # Conditions: # 1. Time to hide def desktop_hideBeginningSplashScreen(p): if ( p.c.recentField == "hideBeginningSplashScreen" ): p.splash.visible = False #} #} # Hide description # # Conditions: # 1. tiles has been mismatched or timed out to to hide after matching def desktop_hideDesc(p): if ( p.c.recentField == "hideMatchingTiles" or p.c.recentField == "mismatchedItems" ): p.desc.visible = False #} #} # Hide matching tiles # # Conditions: # 1. Time to hide matching items def desktop_hideMatchingTiles(p): if ( p.c.recentField == "hideMatchingTiles" ): for id in p.c.selectedItems: p.deselectedTiles[id].visible = False p.selectedTiles[id].visible = False #} #} #} # Hide title # # Conditions: # 1. tiles has been mismatched or timed out to to hide after matching def desktop_hideTitle(p): if ( p.c.recentField == "hideMatchingTiles" or p.c.recentField == "mismatchedItems" ): p.title.visible = False #} #} # Load description textures def desktop_loadDescTextures(p): texs = [] for (id, td) in enumerate(p.c.descTextureDescriptions): tex = arcade.load_texture( td.fileName, x = td.x, y = td.y, width = td.width, height = td.height ) texs.append(tex) #} p.descTextures = texs #} # Load beginning and ending textures def desktop_loadSplashTextures(p): texs = [] for (id, td) in enumerate(p.c.splashTextureDescriptions): tex = arcade.load_texture( td.fileName, x = td.x, y = td.y, width = td.width, height = td.height ) texs.append(tex) print(f"desktop_loadST: '{tex}'") #} p.splashTextures = texs #} # Load tile textures 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 #} # Load tiTLe textures def desktop_loadTitleTextures(p): texs = [] for (id, td) in enumerate(p.c.titleTextureDescriptions): tex = arcade.load_texture( td.fileName, x = td.x, y = td.y, width = td.width, height = td.height ) texs.append(tex) #} p.titleTextures = 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 display of the ending splash screen # # Conditions: # 1. just finished removing all tiles def desktop_scheduleDisplayOfEndingSplashScreen(p): if ( p.c.recentField == "victory" ): p.sequentialTimer.schedule("displayEndingSplashScreen", True, p.c.splashEndDelay) #} #} # 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) #} #} # Postpone hiding of the beginning splash screen # # Conditions: # 1. just launched the game def desktop_scheduleHidingOfBeginningSplashScreen(p): if ( p.c.recentField == "splashBeginTimeout" ): p.sequentialTimer.schedule("hideBeginningSplashScreen", True, p.c.splashBeginTimeout) #} #}