How to use FindByTag method in websmith

Best Python code snippet using websmith_python

Level1_3.py

Source:Level1_3.py Github

copy

Full Screen

1from game.Player import Player2from game.Resources import tileSizeNum, tileSize, Resources, setBgMusic3from game.entities.Goomba import Goomba4from game.entities.KoopaTroopa import KoopaTroopa5from game.entities.Platform import Platform6from game.hud.Coins import Coins7from game.hud.Level import Level8from game.hud.Score import Score9from game.hud.Time import Time10from game.levels.Level1_1 import getClassByName11from game.scripts import FollowPlayer12from game.technical.Trigger import Trigger13from gameengine.core.Scene import Scene14from gameengine.core.World import World15from gameengine.loaders.LevelLoader import LevelLoader16class Level1_3(Scene):17 major = 118 minor = 319 def onLoad(self):20 if not World.findByTag("Score"):21 score = World.instantiate(Score, (80, self.mainCamera.size.y - 50))22 score.keepBetweenScenes = True23 if not World.findByTag("Coins"):24 coins = World.instantiate(Coins, (400, self.mainCamera.size.y - 50))25 coins.keepBetweenScenes = True26 if not World.findByTag("Level"):27 level = World.instantiate(Level, (800, self.mainCamera.size.y - 50))28 level.keepBetweenScenes = True29 if not World.findByTag("Time"):30 time = World.instantiate(Time, (1100, self.mainCamera.size.y - 50))31 time.keepBetweenScenes = True32 World.findByTag("Level")[0].major = 133 World.findByTag("Level")[0].minor = 334 time = World.findByTag("Time")[0]35 time.fastMusic = Resources.owMusicFast36 time.time = 50037 time.restart()38 setBgMusic(Resources.owMusic).play()39 LevelLoader.loadMap("res/maps/level1-3.tmx", getClassByName)40 def f():41 World.instantiate(Goomba, (tileSizeNum * 44, tileSizeNum * 11))42 World.instantiate(Goomba, (tileSizeNum * 46, tileSizeNum * 11))43 onGroundY = tileSize.y * 244 World.instantiate(Trigger, (tileSizeNum * 24, onGroundY), (1, 1000), "Player", f)45 World.instantiate(KoopaTroopa, (tileSizeNum * 29, tileSizeNum * 11), smart=True)46 World.instantiate(Platform, (tileSizeNum * 54.5, 0), Platform.SmoothUpDown, tileSizeNum * 9)47 World.instantiate(Platform, (tileSizeNum * 82, tileSizeNum * 5), Platform.SmoothLeftRight, tileSizeNum * 85.5)48 World.instantiate(Platform, (tileSizeNum * 89, tileSizeNum * 4), Platform.SmoothLeftRight, tileSizeNum * 93.5)49 World.instantiate(Platform, (tileSizeNum * 129, tileSizeNum * 8), Platform.SmoothLeftRight, tileSizeNum * 131.5)50 if not World.findByTag("Player"):51 onGroundY = tileSize.y * 252 player = World.instantiate(Player, (tileSizeNum * 5, onGroundY))53 # player = World.instantiate(Player, (tileSizeNum * 77, onGroundY + tileSizeNum * 8))54 # player = World.instantiate(Player, (tileSizeNum * 120, onGroundY + tileSizeNum * 8))55 player.keepBetweenScenes = True56 World.findByTag("Player")[0].transform.position = (tileSizeNum * 5, onGroundY)57 # World.findByTag("Player")[0].transform.position = (tileSizeNum * 130, onGroundY)58 def restart():59 Player.lives = 060 World.destroy(World.findByTag("Player")[0])61 World.findByTag("Flag")[0].prepareNextLevel = restart62 self.mainCamera.addScript(FollowPlayer, 138)63 self.mainCamera.zoom = 364 self.mainCamera.backgroundColor = (107, 140, 255, 0)...

Full Screen

Full Screen

LevelSplash.py

Source:LevelSplash.py Github

copy

Full Screen

1from typing import Type2from game.hud.Coins import Coins3from game.hud.Level import Level4from game.hud.Score import Score5from game.hud.Time import Time6from gameengine.components.Label import Label7from gameengine.core.Scene import Scene8from gameengine.core.Script import Script9from gameengine.core.Timer import Timer10from gameengine.core.World import World11from gameengine.managers.DrawingManager import DrawingManager12from gameengine.managers.SceneManager import SceneManager13class LevelSplash(Scene):14 def onLoad(self, nextLevel: Type[Scene], major, minor):15 self.mainCamera.backgroundColor = (0, 0, 0, 0)16 self.mainCamera.zoom = 317 if not World.findByTag("Score"):18 score = World.instantiate(Score, (80, self.mainCamera.size.y - 50))19 score.keepBetweenScenes = True20 if not World.findByTag("Coins"):21 coins = World.instantiate(Coins, (400, self.mainCamera.size.y - 50))22 coins.keepBetweenScenes = True23 if not World.findByTag("Level"):24 level = World.instantiate(Level, (800, self.mainCamera.size.y - 50))25 level.keepBetweenScenes = True26 if not World.findByTag("Time"):27 time = World.instantiate(Time, (1100, self.mainCamera.size.y - 50))28 time.keepBetweenScenes = True29 World.findByTag("Level")[0].major = major30 World.findByTag("Level")[0].minor = minor31 worldLabel = World.instantiate(Label, (500, 400))32 worldLabel.text = "World {}-{}".format(major, minor)33 worldLabel.font_name = "Emulogic"34 worldLabel.font_size = 2235 worldLabel.set_style("align", "center")36 DrawingManager().GUI.add(worldLabel)37 lifesLabel = World.instantiate(Label, (500, 325))38 # players = World.findByTag("Player")39 # player = players[0] if players else None40 from game.Player import Player41 lifesLabel.text = "lives * {}".format(Player.lives)42 lifesLabel.font_name = "Emulogic"43 lifesLabel.font_size = 2244 lifesLabel.set_style("align", "right")45 DrawingManager().GUI.add(lifesLabel)46 def loadNextLevel():47 DrawingManager().remove(worldLabel)48 DrawingManager().GUI.remove(worldLabel)49 DrawingManager().remove(lifesLabel)50 DrawingManager().GUI.remove(lifesLabel)51 SceneManager().loadScene(nextLevel)52 # Prevent player falling while loading level53 class KeepPlayerFromFalling(Script):54 def init(self, *args, **kwargs):55 self.player = None56 players = World.findByTag("Player")57 if players:58 self.player = players[0]59 def onUpdate(self):60 if self.player:61 from gameengine.components.Physics import Physics62 self.player.getComponent(Physics).velocity.y = 063 from gameengine.core.GameObject import GameObject64 go = World.instantiate(GameObject, (0, 0))65 go.addScript(KeepPlayerFromFalling)...

Full Screen

Full Screen

LevelDeniss.py

Source:LevelDeniss.py Github

copy

Full Screen

1from game.Player import Player2from game.Resources import tileSizeNum, tileSize, Resources, setBgMusic3from game.hud.Coins import Coins4from game.hud.Level import Level5from game.hud.Score import Score6from game.hud.Time import Time7from game.levels.Level1_1 import getClassByName8from game.scripts import FollowPlayer9from gameengine.core.Scene import Scene10from gameengine.core.World import World11from gameengine.loaders.LevelLoader import LevelLoader12class LevelDeniss(Scene):13 def onLoad(self):14 if not World.findByTag("Score"):15 score = World.instantiate(Score, (80, self.mainCamera.size.y - 50))16 score.keepBetweenScenes = True17 if not World.findByTag("Coins"):18 coins = World.instantiate(Coins, (400, self.mainCamera.size.y - 50))19 coins.keepBetweenScenes = True20 if not World.findByTag("Level"):21 level = World.instantiate(Level, (800, self.mainCamera.size.y - 50))22 level.keepBetweenScenes = True23 if not World.findByTag("Time"):24 time = World.instantiate(Time, (1100, self.mainCamera.size.y - 50))25 time.keepBetweenScenes = True26 World.findByTag("Level")[0].major = 127 World.findByTag("Level")[0].minor = 4228 World.findByTag("Time")[0].fastMusic = Resources.owMusicFast29 setBgMusic(Resources.owMusic).play()30 LevelLoader.loadMap("res/maps/levelDeniss.tmx", getClassByName)31 if not World.findByTag("Player"):32 onGroundY = tileSize.y * 233 player = World.instantiate(Player, (tileSizeNum * 5, onGroundY))34 # player = World.instantiate(Player, (tileSizeNum * 77, onGroundY + tileSizeNum * 8))35 # player = World.instantiate(Player, (tileSizeNum * 120, onGroundY + tileSizeNum * 8))36 player.keepBetweenScenes = True37 self.mainCamera.addScript(FollowPlayer, 180)38 self.mainCamera.zoom = 339 self.mainCamera.backgroundColor = (107, 140, 255, 0)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run websmith automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful