def GetAttrFromFile(self, FilePath): self.position.x = float(GetAttribute(FilePath, "Transform", "PosX")) self.position.y = float(GetAttribute(FilePath, "Transform", "PosY")) self.Rotation = float(GetAttribute(FilePath, "Transform", "rotation")) self.Size.x = float(GetAttribute(FilePath, "Transform", "sizeX")) self.Size.y = float(GetAttribute(FilePath, "Transform", "sizeY")) self.Color.x = float(GetAttribute(FilePath, "Sprite", "ColorR")) self.Color.y = float(GetAttribute(FilePath, "Sprite", "ColorG")) self.Color.z = float(GetAttribute(FilePath, "Sprite", "ColorB")) self.Alpha = float(GetAttribute(FilePath, "Sprite", "Alpha")) self.Texture = GetAttribute(FilePath, "Sprite", "textureName") self.Grid.x = int(GetAttribute(FilePath, "Sprite", "GridX")) self.Grid.y = int(GetAttribute(FilePath, "Sprite", "GridY")) self.Selected.x = int(GetAttribute(FilePath, "Sprite", "SelectedX")) self.Selected.y = int(GetAttribute(FilePath, "Sprite", "SelectedY")) isAlpha = int(GetAttribute(FilePath, "Sprite", "isAlpha")) if self.Texture in Resources.Textures: pass else: Resources.LoadTexture( GetAttribute(FilePath, "Sprite", "texturePath"), isAlpha, self.Texture)
def setNewTexture(self, texturePath, isAlpha, key): if key in Resources.Textures: pass else: Resources.LoadTexture(texturePath, isAlpha, key) self.Texture = key
def __init__(self, textsheet, textsheetPath, xmlPath): self.textSheet = textsheet self.textSheetPath = textsheetPath self.XML = xmlPath self.Text = "" self.position = glm.vec2(0, 0) self.size = glm.vec2(0, 0) self.rotation = float(0) self.color = glm.vec3(1.0, 1.0, 1.0) self.Grid = glm.vec2(12, 14) Resources.LoadTexture(textsheetPath, 1, textsheet)
def InitLevel(self): super().InitLevel() # self.System.SpriteRenderer.ChangeShader(Resources.Shaders["ShaderV2"]) Resources.LoadTexture("/Textures/block.png", 0, "block") Resources.LoadTexture("/Textures/block.png", 0, "block_solid") Resources.LoadTexture("/Textures/paddle.png", 1, "paddle") Resources.LoadTexture("/Textures/background.jpg", 0, "background") Resources.LoadTexture("/Textures/bg5.jpg", 0, "background2") Resources.LoadTexture("/Textures/sci_fi_bg1.jpg", 0, "background3") Resources.LoadTexture("/Textures/ball.png", 1, "ball") Resources.LoadTexture("/Textures/spikedball.png", 1, "spikedball") Resources.LoadTexture("/Textures/glasspaddle2.png", 1, "glasspaddle") Resources.LoadTexture("/Textures/particle.png", 1, "particle") # make player object PlayerPos = GetVec2(self.System.windowWidth / 2 - Player_Size.x / 2, self.System.windowHeight - Player_Size.y) self.Player = Player() self.Player.position = PlayerPos self.Player.Size = Player_Size self.Player.Velocity = GetVec2(Player_Velocity, 0.0) self.Player.Texture = "glasspaddle" # make ball object BallPos = PlayerPos + GetVec2(Player_Size.x / 2 - Ball_Radius, -Ball_Radius * 2) self.Ball = BallObject() self.Ball.position = BallPos self.Ball.Radius = Ball_Radius self.Ball.Size = GetVec2(Ball_Radius * 2, Ball_Radius * 2) self.Ball.Velocity = Ball_Velocity self.Ball.Texture = "spikedball" self.gameObjects.append(self.Player) self.gameObjects.append(self.Ball) # Load Levels self.Load(PathToProject() + "Game/levels/level0.txt", self.System.windowWidth, self.System.windowHeight * 0.5) self.pGenerator = self.System.GetGenerator(Resources.Textures["particle"], 100)
def InitLevel(self): super().InitLevel() self.player = Player(PathToProject() + "res/GameObjects/PlayerShip.xml") block1 = Block(PathToProject() + "res/GameObjects/block.xml") block2 = Block(PathToProject() + "res/GameObjects/block.xml") block2.position.x = 800 self.textManager = TextManager("textsheet", "/Text/8x8text_whiteNoShadow.png", "/Text/textCoord.xml") self.audio = AudioManager() self.audio.LoadSound("/SoundEffects/scifi_weapon1.wav", "wep1") Resources.LoadTexture("/Textures/ball.png", 1, "particle") self.PGen = self.System.GetGenerator(Resources.GetTexture("particle"), 50) self.AddObject(block1) self.AddObject(block2) self.AddObject(self.player)
def InitScene(self): # Load Textures Resources.LoadTexture("/Textures/player.png", 1, "playerShip") Resources.LoadTexture("/Textures/block.png", 0, "block") Resources.LoadTexture("/Textures/block_solid.png", 0, "block_solid") Resources.LoadTexture("/Textures/paddle.png", 1, "paddle") Resources.LoadTexture("/Textures/background.jpg", 0, "background") Resources.LoadTexture("/Textures/bg5.jpg", 0, "background2") Resources.LoadTexture("/Textures/sci_fi_bg1.jpg", 0, "background3") Resources.LoadTexture("/Textures/ball.png", 1, "ball") Resources.LoadTexture("/Textures/spikedball.png", 1, "spikedball") Resources.LoadTexture("/Textures/glasspaddle2.png", 1, "glasspaddle") Resources.LoadTexture("/Textures/particle.png", 1, "particle") Resources.LoadTexture("/Textures/cartoonship red.png", 1, "RedShip") Resources.LoadTexture("/Textures/DurrrSpaceShip.png", 1, "PlayerShip2") Resources.LoadTexture("/Textures/boss2.png", 1, "boss") self.player = Player() self.player.position = GetVec2(self.System.windowWidth / 2 - Player_Size.x / 2, self.System.windowHeight / 2 - Player_Size.x / 2) self.player.Size = Player_Size self.player.Health = 3 self.player.Texture = "PlayerShip2" self.player.Velocity = Player_Velocity self.background = "background2" self.ShipAmount = 15 self.BossAmount = 15 self.SceneWidth = self.System.windowWidth self.SceneHeight = self.System.windowHeight self.Txt = TextManager("textsheet", "/Text/8x8text_whiteNoShadow.png", "/Text/textCoord.xml") self.audio = AudioManager() self.audio.LoadSound("/SoundEffects/scifi_weapon1.wav", "wep1") self.audio.LoadSound("/SoundEffects/NewHorizons.wav", "music1")
def InitLevel(self): super().InitLevel() Resources.LoadTexture("/Textures/sci_fi_bg1.jpg", 0, "background3") self.textManager = TextManager("textsheet", "/Text/8x8text_whiteNoShadow.png", "/Text/textCoord.xml")
def LoadTextureToResources(texturePath, isAlpha, key): if key in Resources.Textures: pass else: Resources.LoadTexture(texturePath, isAlpha, key)
def InitLevel(self): super().InitLevel() # load resources Resources.LoadTexture("/Textures/tile_spritesheet.png", 1, "TileSheet") Resources.LoadTexture("/Textures/sci_fi_bg1.jpg", 0, "background") self.background = Object() self.background.position = GetVec2(0, 0) self.background.Size = GetVec2(self.levelWidth, self.levelHeight) self.background.Color = GetVec3(0.3, 0.3, 0.5) self.background.Texture = "background" self.background.TexID = 0 self.bg2 = Object() self.bg2.position = GetVec2(self.levelWidth, 0) self.bg2.Size = GetVec2(self.levelWidth, self.levelHeight) self.bg2.Color = GetVec3(0.3, 0.3, 0.5) self.bg2.Texture = "background" self.bg2.TexID = 0 self.bg3 = Object() self.bg3.position = GetVec2(-1600, 0) self.bg3.Size = GetVec2(self.levelWidth, self.levelHeight) self.bg3.Color = GetVec3(0.3, 0.3, 0.5) self.bg3.Texture = "background" self.bg3.TexID = 0 self.Camera = self.System.Camera # init objects idleAnimation = Animation() idleAnimation.speed = 0.25 idleAnimation.AnimationList = [ GetVec2(1, 1), GetVec2(2, 1), GetVec2(3, 1), GetVec2(4, 1) ] walkingAnimation = Animation() walkingAnimation.speed = 0.20 walkingAnimation.AnimationList = [ GetVec2(1, 2), GetVec2(2, 2), GetVec2(3, 2), GetVec2(4, 2), GetVec2(5, 2), GetVec2(6, 2) ] jumpAnimation = Animation() jumpAnimation.speed = 0.20 jumpAnimation.AnimationList = [ GetVec2(7, 2), GetVec2(8, 2), GetVec2(1, 3), GetVec2(2, 3), GetVec2(3, 3), GetVec2(4, 3), GetVec2(5, 3), GetVec2(6, 3), GetVec2(7, 3), GetVec2(8, 3) ] attackAnimation = Animation() attackAnimation.speed = 0.15 attackAnimation.AnimationList = [ GetVec2(1, 7), GetVec2(2, 7), GetVec2(3, 7), GetVec2(4, 7), GetVec2(5, 7), ] Player1 = Player(PathToProject() + "res/GameObjects/Player.xml") Player1.Animated = True Player1.addAnimation(idleAnimation) Player1.addAnimation(walkingAnimation) Player1.addAnimation(jumpAnimation) Player1.addAnimation(attackAnimation) Player1.position = GetVec2(200, 200) Player1.TexID = 2 Player1.VerticalFlip = 1 Player1.Velocity = GetVec2(0, 0) self.player = Player1 testTile = Tile() testTile.position = GetVec2(500, 500) testTile.Size = GetVec2(100, 100) testTile.Grid = GetVec2(6, 4) testTile.Selected = GetVec2(3, 2) testTile.TexID = 1 testTile.Texture = "TileSheet" testTile2 = Tile() testTile2.position = GetVec2(100, 500) testTile2.Size = GetVec2(200, 200) testTile2.Grid = GetVec2(6, 4) testTile2.Selected = GetVec2(3, 4) testTile2.TexID = 1 testTile2.Texture = "TileSheet" # self.AddObject(player) self.AddObject(Player1) self.staticObjects.append(testTile) self.staticObjects.append(testTile2) self.MakeLevel("Game3/level1.txt", self.levelWidth, self.levelHeight)