def update(self, dt): super().update(dt) game = self.activity.activityObjects["game"] self.texture = IO_TextureManager.getInstance().textureMap[ "curr_" + game.player.name] self.leveltexture = IO_TextureManager.getInstance().textureMap[ "level" + str(game.currentLevel + 1)]
def __init__(self, property: IO_Property, name="arrow", axis=-1): super().__init__(property, name) self.texture = IO_TextureManager.getInstance().textureMap["Rock2"] self.force = IO_Vector(x=5, y=0) self.rigidBody.gravity = IO_Vector() self.force *= axis self.axis = axis
def parse(self,source): xmlRoot = IO_XmlHandler.getRoot(source) xmlspriteanimations = IO_XmlHandler.getChild(xmlRoot,"spriteanimations") xmlspriteanimation = xmlspriteanimations[0] xmlspriteanimations = IO_XmlHandler.getChild(xmlspriteanimation,"spriteanimation") for xmlspriteanimation in xmlspriteanimations: id = IO_XmlHandler.getAttribute(xmlspriteanimation,"id") texture = IO_XmlHandler.getAttribute(xmlspriteanimation,"texture") frameW = float(IO_XmlHandler.getAttribute(xmlspriteanimation,"frameW")) frameH = float(IO_XmlHandler.getAttribute(xmlspriteanimation,"frameH")) row = int(IO_XmlHandler.getAttribute(xmlspriteanimation,"row")) frameCount = int(IO_XmlHandler.getAttribute(xmlspriteanimation,"frameCount")) repeat = IO_XmlHandler.getAttribute(xmlspriteanimation,"repeat") == "True" speed = float(IO_XmlHandler.getAttribute(xmlspriteanimation,"speed")) scaleX = float(IO_XmlHandler.getAttribute(xmlspriteanimation,"scaleX")) scaleY = float(IO_XmlHandler.getAttribute(xmlspriteanimation,"scaleY")) angle = float(IO_XmlHandler.getAttribute(xmlspriteanimation,"angle")) flipX = IO_XmlHandler.getAttribute(xmlspriteanimation,"flipX") == "True" flipY = IO_XmlHandler.getAttribute(xmlspriteanimation,"flipY") == "True" texture =IO_TextureManager.getInstance().textureMap[texture] self.animationMap[id] = IO_SpriteAnimation(texture,id,(frameW,frameH),row,frameCount,repeat,speed=speed,scale= (scaleX,scaleY),rotation=angle,flip=(flipX,flipY)) xmlsequenceanimations = IO_XmlHandler.getChild(xmlRoot,"sequenceanimations") xmlsequenceanimation = xmlsequenceanimations[0] xmlsequenceanimations = IO_XmlHandler.getChild(xmlsequenceanimation,"sequenceanimation") for xmlsequenceanimation in xmlsequenceanimations: id = IO_XmlHandler.getAttribute(xmlsequenceanimation,"id") repeat = IO_XmlHandler.getAttribute(xmlsequenceanimation,"repeat") == "True" speed = float(IO_XmlHandler.getAttribute(xmlsequenceanimation,"speed")) scaleX = float(IO_XmlHandler.getAttribute(xmlsequenceanimation,"scaleX")) scaleY = float(IO_XmlHandler.getAttribute(xmlsequenceanimation,"scaleY")) angle = float(IO_XmlHandler.getAttribute(xmlsequenceanimation,"angle")) flipX = IO_XmlHandler.getAttribute(xmlsequenceanimation,"flipX") == True flipY = IO_XmlHandler.getAttribute(xmlsequenceanimation,"flipY") == True xmltextures =IO_XmlHandler.getChild(xmlsequenceanimation,"texture") frameCount = len(xmltextures) textures = [] for xmltexture in xmltextures: textureid = IO_XmlHandler.getAttribute(xmltexture,"id")
def init(self, screenSize: tuple[int, int] = IO_SCREEN_SIZE, screenColor: tuple[int, int, int, int] = IO_SCREEN_COLOR, screenTitle: str = IO_SCREEN_TITLE) -> None: """ @purpose initlize IO_Screen member variable\n @param[0] self IO_Screen\n @param[1] self screenSize\n @param[2] self screenColor\n @param[3] self screenTitle\n """ pygame.init() self.screen = IO_Screen.getInstance() self.inputHandler = IO_InputHandler.getInstance() self.textureManager = IO_TextureManager.getInstance() self.animationHandler = IO_AnimationHandler.getInstance() self.mapManager = IO_MapManager.getInstance() self.collisionHandler = IO_CollisonHandler.getInstance() self.camera = IO_Camera.getInstance() self.actorManager = IO_ActorManager.getInstance() self.mixer = IO_MusicManager.getInstance() self.game = Game.getInstance() self.levelManager = LevelManager.getInstance() self.ui = IO_UserInterface.getInstance() self.textureManager.parse("asset/texture.xml") self.animationHandler.parse("asset/animation.xml") self.mapManager.parse("asset/map.xml") self.levelManager.parse("asset/level.xml") self.mixer.parse("asset/sound.xml") self.ui.parse("asset/ui.xml") self.screen.init(screenSize, screenColor, screenTitle) self.camera.init(IO_SCREEN_SIZE) self.mapManager.origin.x = 259 self.mapManager.origin.y = 165 self.ui.init() self.camera.target = self.mapManager
def render(self, dt: float) -> None: super().render(dt) if super().onHover(): IO_TextureManager.getInstance().textureMap["rule"].draw( destination=(84, 20), screenPos=True)
def __init__(self, prop, name, activity): super().__init__(prop=prop, name=name, activity=activity) self.texture = IO_TextureManager.getInstance().textureMap["instruct"] self.instruct = IO_TextureManager.getInstance().textureMap["rule"]
def __init__(self, prop, name, activity): super().__init__(prop=prop, name=name, activity=activity) self.texture = IO_TextureManager.getInstance().textureMap["curr_Dude"] self.leveltexture = IO_TextureManager.getInstance( ).textureMap["level1"]
def __init__(self, prop, name, activity): super().__init__(prop=prop, name=name, activity=activity) self.texture = IO_TextureManager.getInstance().textureMap["quit"]
def __init__(self, prop, name, level, activity): super().__init__(prop=prop, name=name, activity=activity) self.level = level self.texture = IO_TextureManager.getInstance().textureMap[ "level" + str(self.level)]
def __init__(self,x : int, y : int,w : int,h : int, num:int, force:IO_Vector = IO_Vector(y=-3)): super().__init__( IO_Property(texture=IO_TextureManager.getInstance().textureMap["obstacle"],x = x, y = y ,w = w, h = h), name="Barrier"+str(num)) self.buttons : list[Button] = [] self.force : IO_Vector = force self.startingpos = IO_Point(self.transform.x,self.transform.y) self.opentime = 40