コード例 #1
0
ファイル: GameLevel.py プロジェクト: kingstonxy/FYPEngine
    def Draw(self):
        self.System.SystemDraw(Resources.GetTexture("background3"), GetVec2(0, 0),
                               GetVec2(self.System.windowWidth, self.System.windowHeight), 0.0,
                               GetVec3(0.3, 0.3, 0.5), GetVec2(1, 1), GetVec2(1, 1))

        for Tile in self.Blocks:
            if not Tile.Destroyed:
                Tile.Draw(self.System)
        self.pGenerator.Draw(self.System)
        super().Draw()
コード例 #2
0
ファイル: GameLevel.py プロジェクト: kingstonxy/FYPEngine
    def ConstructLevel(self, BlockData, LevelWidth, LevelHeight):

        height = len(BlockData)
        width = len(BlockData[0])

        UnitWidth = float(LevelWidth / width)
        UnitHeight = float(LevelHeight / height)
        IndexY = 0
        for y in BlockData:

            IndexX = 0
            for x in y:

                if int(x) == 1:
                    Pos = GetVec2(UnitWidth * float(IndexX), UnitHeight * float(IndexY))
                    Size = GetVec2(UnitWidth, UnitHeight)
                    Color = GetVec3(0.9, 0.9, 0.9)

                    Obj = GameObject()
                    Obj.position = Pos
                    Obj.Size = Size
                    Obj.Color = Color
                    Obj.Texture = "block_solid"
                    Obj.IsSolid = True
                    self.Blocks.append(Obj)

                elif int(x) > 1:
                    color = GetVec3(1.0, 1.0, 1.0)
                    Pos = GetVec2(UnitWidth * float(IndexX), UnitHeight * float(IndexY))
                    Size = GetVec2(UnitWidth, UnitHeight)

                    if int(x) == 2:
                        color = GetVec3(0.0, 1.0, 1.3)
                    elif int(x) == 3:
                        color = GetVec3(1.3, 1.0, 0.0)
                    elif int(x) == 4:
                        color = GetVec3(0.5, 1.3, 0.0)
                    elif int(x) == 5:
                        color = GetVec3(1.3, 0.3, 0.5)

                    Obj = GameObject()
                    Obj.position = Pos
                    Obj.Size = Size
                    Obj.Color = color
                    Obj.Texture = "block"
                    Obj.IsSolid = False
                    self.Blocks.append(Obj)

                IndexX = IndexX + 1
                # print(x, IndexX)

            IndexY = IndexY + 1
コード例 #3
0
 def MakeProjectile(self, texture, dt, audio):
     if self.Timer >= self.RoF:
         self.Timer = 0
         newProjectile = Projectile()
         newProjectile.position = GetVec2(self.position.x + self.Size.x / 2,
                                          self.position.y + self.Size.y / 2)
         newProjectile.Size = GetVec2(10, 50)
         newProjectile.Velocity = GetVec2(0.0, -600.0)
         newProjectile.Rotation = 0.0
         newProjectile.Color = GetVec3(1.3, 0.3, 0.1)
         newProjectile.Texture = texture
         self.ProjectileList.append(newProjectile)
         audio.Play("wep1")
コード例 #4
0
ファイル: GameLevel.py プロジェクト: kingstonxy/FYPEngine
    def Update(self, dt):
        super().Update(dt)
        self.System.UpdateCamera(0, 0, 0, 0)

        self.Player.ProccessInput(dt, self.System, self.Ball)
        keys = self.System.GetInput()

        if keys[self.System.getKey("Q")]:
            for Tile in self.Blocks:
                if Tile.Destroyed is not True:
                    Tile.Destroyed = True

        # print(1/dt)
        self.Ball.BallMove(dt, self.System.windowWidth)
        self.BlockCollision()

        # self.PGen.Update(dt, self.Ball, 20, glm.vec2(self.Ball.Radius / 2))
        if self.Ball.position.y >= self.System.windowHeight:
            self.ResetLevel()
            self.ResetPlayer()

        if self.IsComplete():
            self.CurrLevel = self.CurrLevel + 1
            # print(self.CurrLevel)

            if self.CurrLevel > 4:
                self.CurrLevel = 0

            self.ResetLevel()
            self.ResetPlayer()
        self.pGenerator.Update(dt, self.Ball, 20, GetVec2(self.Ball.Radius / 2, self.Ball.Radius / 2))
コード例 #5
0
ファイル: GameScene.py プロジェクト: kingstonxy/FYPEngine
    def CheckLoss(self):
        ShipIndex = 0
        for ship in self.gameObjects:
            if ship.position.y >= (self.SceneHeight + 50):
                self.player.Health = self.player.Health - 1
                self.DelShip(ShipIndex)
            ShipIndex = ShipIndex + 1

        if self.player.Health <= 0:
            self.Txt.DrawString(self.System, "GAMEOVER", GetVec2(self.SceneWidth/2, self.SceneHeight/2))
コード例 #6
0
ファイル: GameLevel.py プロジェクト: kingstonxy/FYPEngine
    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)
コード例 #7
0
    def ConstructLevel(self, data, width, height):
        gapWidth = 64
        gapHeight = 64
        blockWidth = 125
        blockHeight = 64
        currPosx = 0
        currPosy = 0

        IndexY = 0
        for y in data:
            IndexX = 0
            for x in y:
                if int(x) == 0:
                    currPosx = 0
                elif int(x) == 1:
                    newTile = Tile(PathToProject() +
                                   "res/GameObjects/Tile1.xml")
                    newTile.TexID = 1
                    newTile.position = GetVec2(IndexX * gapWidth + currPosx,
                                               IndexY * gapHeight)
                    self.staticObjects.append(newTile)
                    currPosx += 61
                elif int(x) == 2:
                    newTile = Tile(PathToProject() +
                                   "res/GameObjects/Tile2.xml")
                    newTile.TexID = 1
                    newTile.position = GetVec2(IndexX * gapWidth + currPosx,
                                               IndexY * gapHeight)
                    self.staticObjects.append(newTile)
                    currPosx += 61
                elif int(x) == 3:
                    newTile = Tile(PathToProject() +
                                   "res/GameObjects/Tile2.xml")
                    newTile.TexID = 1
                    newTile.position = GetVec2(IndexX * gapWidth + currPosx,
                                               IndexY * gapHeight)
                    self.staticObjects.append(newTile)
                    currPosx += 61
                IndexX += 1
            IndexY += 1
コード例 #8
0
ファイル: GameScene.py プロジェクト: kingstonxy/FYPEngine
    def UpdateScene(self, amount, dt):
        self.RemoveDead()

        for ship in self.gameObjects:
            ship.position = ship.position + (ship.Velocity * dt)

        if self.SpawnTimer >= 2:
            for x in range(0, amount):
                if self.ShipAmount > 0:
                    randPos = GetVec2(random.uniform(150, self.SceneWidth - 150), 0.0)
                    size = GetVec2(86, 86)
                    velocity = GetVec2(0, 100)
                    NewShip = Ship()
                    NewShip.position = randPos
                    NewShip.Size = size
                    NewShip.Velocity = velocity
                    NewShip.Health = 3
                    NewShip.Texture = "RedShip"

                    self.gameObjects.append(NewShip)
                self.ShipAmount = self.ShipAmount - 1
            self.SpawnTimer = 0
        self.SpawnTimer = self.SpawnTimer + dt
コード例 #9
0
ファイル: level.py プロジェクト: kingstonxy/FYPEngine
    def Update(self, dt):
        self.player.ProccessInput(dt, self.System)
        self.flag = 0
        for obj in self.gameObjects:

            if obj != self.player:
                if self.player.DetectCollision(obj):
                    self.flag = 1

                    if self.timer > 1:
                        self.audio.Play("wep1")
                        self.timer = 0
                    self.timer += dt
        self.System.UpdateCamera(self.player.position.x + self.player.Size.x / 2 - self.System.windowWidth / 2,
                                 self.player.position.y + self.player.Size.y / 2 - self.System.windowHeight / 2, 0, 0)
        super().Update(dt)
        self.PGen.Update(dt, self.player, 2, 10, GetVec2((self.player.position.x+self.player.Size.x/2)-10,
                                                         self.player.position.y+self.player.Size.y-20), 1.5, 0.5, 0.5)
コード例 #10
0
ファイル: GameScene.py プロジェクト: kingstonxy/FYPEngine
    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")
コード例 #11
0
ファイル: GameScene.py プロジェクト: kingstonxy/FYPEngine
 def StartScene(self, system, backgroundColor):
     system.SystemDraw(Resources.GetTexture(self.background), GetVec2(0, 0),
                       GetVec2(self.SceneWidth, self.SceneHeight),
                       0.0, backgroundColor, GetVec2(1, 1), GetVec2(1, 1))
コード例 #12
0
ファイル: GameScene.py プロジェクト: kingstonxy/FYPEngine
import random
import sys

sys.path.append(sys.path[0] + "/../")
from Game2.GameObjects import Ship
from Game2.GameObjects import Player
from Source.Renderer.ResourseManager import Resources
from Source.System.LevelManager import LevelManager
from Source.Utility.glmVec import GetVec2, GetVec3
from Source.System.TextManager import TextManager
from Source.System.audioManager import AudioManager

Player_Velocity = float(550.0)
Player_Size = GetVec2(125, 125)


class Scene(LevelManager):
    def __init__(self, ships, bosses, width, height, system):
        super().__init__(system)
        self.player = None
        self.background = ""
        self.ShipAmount = ships
        self.BossAmount = bosses
        self.SceneWidth = width
        self.SceneHeight = height
        self.gameObjects = []
        self.SpawnTimer = 0
        self.Txt = None
        self.audio = None
        self.score = 0
コード例 #13
0
ファイル: GameLevel.py プロジェクト: kingstonxy/FYPEngine
    def Draw(self):

        self.System.SystemDraw(Resources.GetTexture("background3"), GetVec2(0, 0),
                               GetVec2(self.System.windowWidth, self.System.windowHeight), 0.0,
                               GetVec3(0.3, 0.3, 0.5), GetVec2(1, 1), GetVec2(1, 1))

        if self.count == 0:
            self.textManager.DrawString(self.System, "START", GetVec2(200, 200), GetVec2(48, 48))
        else:
            self.textManager.DrawString(self.System, "START", GetVec2(200, 200), GetVec2(48, 48), GetVec3(0.5, 0.5, 0.5))

        if self.count == 1:
            self.textManager.DrawString(self.System, "EXIT", GetVec2(200, 300), GetVec2(48, 48))
        else:
            self.textManager.DrawString(self.System, "EXIT", GetVec2(200, 300), GetVec2(48, 48), GetVec3(0.5, 0.5, 0.5))
コード例 #14
0
ファイル: GameLevel.py プロジェクト: kingstonxy/FYPEngine
 def ResetPlayer(self):
     self.Player.Size = Player_Size
     PlayerPos = GetVec2(self.System.windowWidth / 2 - Player_Size.x / 2, self.System.windowHeight - Player_Size.y)
     self.Player.position = PlayerPos
     self.Ball.Reset(PlayerPos + GetVec2(Player_Size.x / 2 - Ball_Radius, -Ball_Radius * 2), Ball_Velocity)
コード例 #15
0
    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)
コード例 #16
0
ファイル: object.py プロジェクト: kingstonxy/FYPEngine
 def __init__(self, filepath=None):
     super().__init__(filepath)
     self.Velocity = GetVec2(200, 200)
     self.ObjectType = "DYNAMIC"
コード例 #17
0
ファイル: GameLevel.py プロジェクト: kingstonxy/FYPEngine
# import glm
import os
import sys

# sys.path.append(os.path.dirname(__file__) + "/../")
sys.path.append(sys.path[0] + "/../")
from Game.GameObject import GameObject, BallObject, Player
from Source.Utility.glmVec import GetVec2, GetVec3, normalize, glmLength
from Source.Utility.XmlUtility import PathToProject
from Source.Renderer.ResourseManager import Resources
from Source.System.TextManager import TextManager
from Source.System.LevelManager import LevelManager

Player_Size = GetVec2(100, 20)
Player_Velocity = float(500.0)
Ball_Velocity = GetVec2(100.0, -350.0)
Ball_Radius = 12.5

Time = 0.0


class Menu(LevelManager):
    def __init__(self, system):
        super().__init__(system)
        self.textManager = None
        self.count = 0
        self.max = 1
        pass

    def InitLevel(self):
        super().InitLevel()