Exemple #1
0
 def defineVariables(self, pos: Vector, color, type, image, length=300):
     self.pos = pos
     self.vel = Vector()
     self.radius = 30
     self.length = length
     self.normalLine = Vector(0, -self.length)
     self.lineLeftGen = Vector(-self.radius * 2, -self.length)
     self.lineRightGen = Vector(+self.radius * 2, -self.length)
     self.line = Line
     self.direction = Vector()
     self.looking = False
     self.rotation = 5
     self.losColour = 'rgb(255,255,0)'
     self.found = False
     self.type = type
     self.soundRange = 100
     self.stealthRange = 150
     self.color = color
     self.speed = 0.45
     self.health = 100
     self.ability = Cannon()
     self.enemyIMG = Enemy2IMG(self.pos, image, 530, 172, 9, 4, [0, 2], 150,
                               150, 0)
     self.stopDistance = 0
     self.updateLOS()
Exemple #2
0
 def __init__(self,pos,vel,baseimage,image,fadedBase,death):
     self.trident = False
     self.pos = pos
     self.vel = vel
     self.detectedRadius = 500
     self.followRadius = 800
     self.speed = 60
     self.direction = Vector()
     self.ability = Cannon()
     self.incrementalTimer = 0
     self.incrementalTimer2 = 0
     self.incrementalTimer3 = 0
     self.incrementalTimer4 = 0
     self.inBoundary = False
     self.positions = []
     self.enemies = []
     self.health = 1000
     self.radius = 100
     self.spawn = False
     self.boss = LynelSprite(self.pos, baseimage, 175, 300, 3, 6, [0, 2],image, 608, 130, 8, 2, [1, 1], fadedBase, 175, 300, 3, 6, [0, 2],death, 270, 50, 6, 1, [0, 0],0)
     self.start(self.pos, baseimage, 175, 300, 3, 6, [0.2],
                image, 608, 130, 8  , 2, [1,1], fadedBase, 175, 300, 3, 6, [0, 2],death, 270, 50, 6, 1, [0, 0],0)
     self.moving = False
     self.generator = Vector(0,-200)
     self.draw = False
     self.fireOrb = simplegui._load_local_image('Resources/images/fireOrb.png')
     self.fire = simplegui._load_local_image('Resources/images/fireBall.png')
     self.fireEnabled = False
     self.death = False
     self.damageResistence = 3
Exemple #3
0
    def update(self, keyboard, zoom, mousePos, offset, frame, timer):
        self.image.updatePlayer(self)
        angle = math.atan2((self.pos + offset).getP()[0] - mousePos[0],
                           (self.pos + offset).getP()[1] - mousePos[1])
        for i in range(len(self.directions)):
            if ((i - 0.5) / len(self.directions) * 2 * math.pi) <= angle <= (
                (i + 0.5) / len(self.directions) * 2 * math.pi):
                self.direction = self.directions[i]
                #  Split for clarity
            elif ((i - 0.5 - len(self.directions)) / len(self.directions) * 2 *
                  math.pi) <= angle <= ((i + 0.5 - len(self.directions)) /
                                        len(self.directions) * 2 * math.pi):
                self.direction = self.directions[i]

        if self.last == 0 and not self.god:
            frame.stop()
            timer.stop()
            import runpy
            file_globals = runpy.run_path("Classes/PyGamesGameOver.py")

        if keyboard.shift:
            if self.rest and self.stamina > 0:
                self.stamina -= self.staminaReg
                self.staminaColor = "red"
                self.running = False
            elif self.rest and self.stamina <= 0:
                self.rest = False

            speed = self.speed
            if self.stamina <= 144 and not self.rest:
                speed = self.speed * 2.5
                self.running = True
                self.stamina += 0.5
                self.staminaColor = "green"
            elif not self.rest:
                self.rest = True
                speed = self.speed
                self.running = False
        else:
            self.running = False
            if self.stamina > 0:
                self.stamina -= self.staminaReg
            else:
                self.staminaColor = "green"
                self.rest = False

            speed = self.speed
        if keyboard.right:
            self.vel.add(Vector(speed, 0))
        if keyboard.left:
            self.vel.add(Vector(-speed, 0))
        if keyboard.up:
            self.vel.add(Vector(0, -speed))
        if keyboard.down:
            self.vel.add(Vector(0, speed))
        self.pos.add(self.vel / zoom)
        self.vel = self.vel.getNormalized() * min(self.vel.length(),
                                                  self.maxSpeed) * 0.935
Exemple #4
0
    def moveScreen(self,offset,playerPos,width,height):
        charPosMinOffset = playerPos + offset
        center = Vector(width/2, height/2)
        maxDisplacement = height * (4 / 5) - center.y
        minDisplacement = height * (11 / 20) - center.y

        #Right
        if charPosMinOffset.x > center.x+maxDisplacement:
            offset.subtract(Vector(abs(center.x+maxDisplacement - charPosMinOffset.x), 0))
        elif charPosMinOffset.x > center.x+minDisplacement:
            offset.subtract(Vector(abs((center.x+minDisplacement) - charPosMinOffset.x)/50, 0))
        #Left
        if charPosMinOffset.x < center.x-maxDisplacement:
            offset.add(Vector(abs((center.x-maxDisplacement) - charPosMinOffset.x), 0))
        elif charPosMinOffset.x < center.x-minDisplacement:
            offset.add(Vector(abs((center.x-minDisplacement) - charPosMinOffset.x)/50, 0))

        #Down
        if charPosMinOffset.y > center.y+maxDisplacement:
            offset.subtract(Vector(0, abs(charPosMinOffset.y - (center.y+maxDisplacement))))
        if charPosMinOffset.y > center.y+minDisplacement:
            offset.subtract(Vector(0, abs(charPosMinOffset.y - (center.y+minDisplacement))/50))

        #Up
        if charPosMinOffset.y < center.y-maxDisplacement:
            offset.add(Vector(0, abs(charPosMinOffset.y - (center.y-maxDisplacement))))
        if charPosMinOffset.y < center.y-minDisplacement:
            offset.add(Vector(0, abs(charPosMinOffset.y - (center.y-minDisplacement))/50))
Exemple #5
0
    def updateLOS(self):
        self.normalGen = Vector((self.pos.x + self.normalLine.x),
                                (self.pos.y + self.normalLine.y))
        self.normalBoundary = Line(self.pos, self.normalGen, "blue")

        self.leftgen = Vector((self.pos.x + self.lineLeftGen.x),
                              (self.pos.y + self.lineLeftGen.y))
        self.leftBoundary = Line(self.pos, self.leftgen, "white")

        self.rightgen = Vector((self.pos.x + self.lineRightGen.x),
                               (self.pos.y + self.lineRightGen.y))
        self.rightBoundary = Line(self.pos, self.rightgen, "white")
Exemple #6
0
    def start(self, frame: simplegui.Frame, width, height):
        self.sprites = []
        self.walls = []
        self.enemies = []
        self.pickups = []
        self.hearts = []
        self.defeated = False
        self.trap = True

        self.zoom = 3
        self.mapSize = Vector(4800, 2700)
        self.startPos = Vector(400, 1150)

        #Load Images
        image_background = simplegui._load_local_image(
            'Resources/images/mahadmap.png')
        Ganon = simplegui._load_local_image("Resources/images/GanonStand.png")
        GanonTrans = simplegui._load_local_image(
            "Resources/images/GanonTrident.png")
        fadedGanon = simplegui._load_local_image(
            "Resources/images/GanonStandFaded.png")
        death = simplegui._load_local_image("Resources/images/death.png")
        image_teleporter = simplegui._load_local_image(
            'Resources/images/blue_power_up.png')

        #Background
        frame.set_canvas_background("#cf1020")
        self.sprites.append(
            Sprite(self.mapSize / 2, image_background, self.mapSize.getP()))

        #Teleporter

        if self.defeated:
            self.teleporter = Sprite(
                Vector(width * self.zoom / 2, height * self.zoom / 2) +
                Vector(1500, 0), image_teleporter, [150, 150])
            self.sprites.append(self.teleporter)

        #Enemies
        self.Boss = LynelBoss(Vector(3325, 1250), Vector(0, 0), Ganon,
                              GanonTrans, fadedGanon, death)
        # Walls
        wallWidth = 50
        self.lineHalfWidth = 8
        self.wallPoints1 = [(267, 939), (540, 941), (540, 1050), (2245, 1050),
                            (2246, 219), (4349, 219),
                            (4349, 2233), (2245, 2233), (2245, 1244),
                            (540, 1228), (540, 1378), (268, 1378), (267, 939)]
        self.wallPoints2 = []
        self.wallPoints = [self.wallPoints1, self.wallPoints2]

        for wallPoint in self.wallPoints:
            for i in range(wallPoint.__len__() - 1):
                pos1 = Vector(wallPoint[i][0], wallPoint[i][1])
                pos2 = Vector(wallPoint[i + 1][0], wallPoint[i + 1][1])
                self.walls.append(Wall(self.lineHalfWidth, pos1, pos2))
 def playerTouchTeleporter(self, teleporter, player, nextMap):
     seperation = (teleporter.pos - player.pos).length()
     if seperation < max(teleporter.dim[0],
                         teleporter.dim[0]) + player.radius:
         player.vel = Vector(0, 0)
         player.pos = teleporter.pos.copy()
         nextMap()
Exemple #8
0
    def detectionArea(self,player:Character):
        if not self.spawn:
            distanceToPlayer = player.pos.copy().subtract(self.pos)
            if distanceToPlayer.length() >= self.detectedRadius+player.radius:
                self.inBoundary = False
                if self.incrementalTimer2 % 1 == 0:
                    self.positions.append(self.pos.copy())
                    if self.positions.__len__() == 10:
                        self.positions.pop(0)
                    self.incrementalTimer2 = 0
                self.incrementalTimer2 += 1

                if self.incrementalTimer % 30 == 0 and not self.moving:
                    self.moving = True
                    self.vel = distanceToPlayer.getNormalized()*self.speed
                    self.incrementalTimer = 0
                self.incrementalTimer += 1
                self.trident = False

            if self.vel.length() < 5:
                self.moving = False
                self.inBoundary = True
                self.positions = []
                self.vel = Vector(0,0)
                if not distanceToPlayer.length() >= self.detectedRadius+player.radius:
                    self.trident = True
Exemple #9
0
 def attack(self, player):
     if (self.radius + player.radius) + 20 >= (self.pos -
                                               player.pos).length():
         self.direction = Vector(0, 0)
         player.damageTaken()
         self.vel.add(self.vel.getNormalized().negate() * 55)
         player.health -= 10
Exemple #10
0
 def nextMap(self):
     global currentMap,offset,projectiles,lasers,teleporter,walls,enemies,pickups,inventory,character,boss,noHearts
     currentMap += 1
     if map.__len__() > currentMap:
         map[currentMap].start(frame,CANVAS_WIDTH,CANVAS_HEIGHT)
         offset = -map[currentMap].startPos + (Vector(CANVAS_WIDTH, CANVAS_HEIGHT) / 2)
         projectiles = []
         lasers = []
         if currentMap != 2:
             teleporter = map[currentMap].teleporter
         walls = map[currentMap].walls
         enemies = map[currentMap].enemies
         pickups = map[currentMap].pickups
         if currentMap == 1:
             inventory = Inventory(CANVAS_WIDTH, CANVAS_HEIGHT,character)
             character.healthInit(HealthIMG, heart1)
             character.healthStart(character.healthOB, 3)
             Cannon().baseDamage = Cannon().resetDamage
             Laser().baseDamage = Laser().resetDamage
             Shotgun().baseDamage = Shotgun().resetDamage
             character.staminaReg = 0.5
             character.stamina = 0
             character.staminaStack=character.speedStack=character.damageStack= 0
         if currentMap == 2:
             boss = map[2].Boss
         character.pos = map[currentMap].startPos
Exemple #11
0
class ManMap:
    def start(self, frame, width, height):
        self.sprites = []
        self.walls = []
        self.enemies = []
        self.pickups = []
        self.hearts = []
        self.zoom = 3
        self.mapSize = Vector(width * self.zoom, height * self.zoom)
        self.startPos = Vector(300, 450)

        #Load Images
        image_background = simplegui._load_local_image(
            'Resources/images/mahadmap.png')
        image_wall = simplegui._load_local_image('Resources/images/Blank.png')
        image_Bat = simplegui._load_local_image('Resources/images/bat.png')
        image_FireEnemy = simplegui._load_local_image(
            'Resources/images/FireEnemy.png')
        image_laser = simplegui._load_local_image("Resources/images/Laser.png")
        image_teleporter = simplegui._load_local_image(
            'Resources/images/blue_power_up.png')

        #Background
        frame.set_canvas_background("#0170FE")
        self.sprites.append(
            Sprite(self.mapSize / 2, image_background, self.mapSize.getP()))

        #Teleporter
        self.teleporter = Sprite(
            Vector(width * 3, height * 3) - Vector(300, 300), image_teleporter,
            [150, 150])
        self.sprites.append(self.teleporter)

        #Pickups
        self.pickups.append(
            Pickup(Vector(300, 300), image_laser, 1, 1, "Ability", "Laser"))

        #Enemies

        #Walls
        wallWidth = 50
        lineHalfWidth = 8
        wallPoints1 = [(182, 309), (87, 309), (87, 460), (182, 460),
                       (182, 410), (746, 410)]
        wallPoints2 = [(746, 744), (1451, 744), (1451, 71), (746, 71),
                       (746, 358), (182, 358)]
        wallPoints = [wallPoints1, wallPoints2]
        for wallPoint in wallPoints:
            for i in range(wallPoint.__len__() - 1):
                pos1 = Vector(wallPoint[i][0], wallPoint[i][1])
                pos2 = Vector(wallPoint[i + 1][0], wallPoint[i + 1][1])
                self.walls.append(Wall(lineHalfWidth, pos1, pos2))

    def draw(self, canvas, offset, character, inventory):
        for sprite in self.sprites:
            sprite.draw(canvas, offset)
Exemple #12
0
    def healthInit(self, HealthIMG, heart1):
        noHearts = 3
        self.previous = 50
        self.healthListInit = []
        for i in range(0, noHearts):
            self.healthListInit.append(
                HealthIMG(Vector(self.previous, 50), heart1))
            self.previous += 50

        self.healthOB = []
        for i in range(0, noHearts):
            self.healthOB.append(self.healthListInit[i])
Exemple #13
0
    def __init__(self, halfThickness, spriteGroup):
        corner1 = spriteGroup.cornerTopLeft
        corner2 = spriteGroup.cornerTopRight
        corner3 = spriteGroup.cornerBottomRight
        corner4 = spriteGroup.cornerBottomLeft

        self.wall1 = Wall(halfThickness, corner1 + Vector(1, halfThickness),
                          corner2 + Vector(1, halfThickness))  #Top
        self.wall2 = Wall(halfThickness, corner2 + Vector(-halfThickness, 1),
                          corner3 + Vector(-halfThickness, 1))  #Right
        self.wall3 = Wall(halfThickness, corner3 + Vector(1, -halfThickness),
                          corner4 + Vector(1, -halfThickness))  #Bottom
        self.wall4 = Wall(halfThickness, corner4 + Vector(halfThickness, 1),
                          corner1 + Vector(halfThickness, 1))  #Left
    def __init__(self, img, columns, rows, scale):
        self.img = img
        self.columns = columns
        self.rows = rows
        self.scale = scale

        self.pos = Vector(0, 0)
        self.imgWidth = self.img.get_width()
        self.imgHeight = self.img.get_height()
        self.frameWidth = self.imgWidth / self.columns
        self.frameHeight = self.imgHeight / self.rows
        self.frameCentreX = self.frameWidth / 2
        self.frameCentreY = self.frameHeight / 2
        self.fr_idx = [0,0]
        self.incrementalTimer = 0
        self.animations = []
        self.currentAnimation = 0
        self.counter = 0
Exemple #15
0
 def updateWalls(self):
     for wallPoint in self.wallPoints:
         for i in range(wallPoint.__len__() - 1):
             pos1 = Vector(wallPoint[i][0], wallPoint[i][1])
             pos2 = Vector(wallPoint[i + 1][0], wallPoint[i + 1][1])
             self.walls.append(Wall(self.lineHalfWidth, pos1, pos2))
Exemple #16
0
class EnemySuper:
    def defineVariables(self, pos: Vector, color, type, image, length=300):
        self.pos = pos
        self.vel = Vector()
        self.radius = 30
        self.length = length
        self.normalLine = Vector(0, -self.length)
        self.lineLeftGen = Vector(-self.radius * 2, -self.length)
        self.lineRightGen = Vector(+self.radius * 2, -self.length)
        self.line = Line
        self.direction = Vector()
        self.looking = False
        self.rotation = 5
        self.losColour = 'rgb(255,255,0)'
        self.found = False
        self.type = type
        self.soundRange = 100
        self.stealthRange = 150
        self.color = color
        self.speed = 0.45
        self.health = 100
        self.ability = Cannon()
        self.enemyIMG = Enemy2IMG(self.pos, image, 530, 172, 9, 4, [0, 2], 150,
                                  150, 0)
        self.stopDistance = 0
        self.updateLOS()

    def spriteUpdate(self, character, enemy):
        self.enemyIMG.updateDirection(character, enemy)
        self.enemyIMG.update(enemy)

    def fire(self, pos: Vector, projectiles: list, lasers: list):
        self.ability.fire(pos, projectiles, lasers, self.pos, "enemy")

    def updateLOS(self):
        self.normalGen = Vector((self.pos.x + self.normalLine.x),
                                (self.pos.y + self.normalLine.y))
        self.normalBoundary = Line(self.pos, self.normalGen, "blue")

        self.leftgen = Vector((self.pos.x + self.lineLeftGen.x),
                              (self.pos.y + self.lineLeftGen.y))
        self.leftBoundary = Line(self.pos, self.leftgen, "white")

        self.rightgen = Vector((self.pos.x + self.lineRightGen.x),
                               (self.pos.y + self.lineRightGen.y))
        self.rightBoundary = Line(self.pos, self.rightgen, "white")

    def update(self, zoom, player):
        self.updateLOS()
        self.inLOS(player)
        self.updateSoundDistance(player)

        self.vel.multiply(0.90)
        if self.found:
            self.vel.add(self.direction.getNormalized() * self.speed)
        self.pos.add(self.vel / zoom)

    def drawLos(self, canvas, offset):
        pass
        canvas.draw_polygon([
            ((self.leftBoundary.pA.x + offset.x),
             (self.leftBoundary.pA.y + offset.y)),
            ((self.leftBoundary.pB.x + offset.x),
             (self.leftBoundary.pB.y + offset.y)),
            ((self.rightBoundary.pB.x + offset.x),
             (self.rightBoundary.pB.y + offset.y)),
        ], 0, "white", self.losColour)

    def draw(self, canvas, offset):
        if not self.found:
            self.drawLos(canvas, offset)
        self.enemyIMG.draw(canvas, offset)

    def stealthDistance(self, player):
        if self.stealthRange >= (self.pos - player.pos).length() and (
                self.pos - player.pos).length() > self.soundRange:
            return True
        return False

    def alertDistance(self, enemy2):
        distanceVector = self.pos.copy().subtract(enemy2.pos)
        if distanceVector.length() <= (self.radius + enemy2.radius):
            enemy2.vel.x = -enemy2.vel.x
        elif distanceVector.length() < 350 and (enemy2.found or self.found):
            enemy2.found = True
            self.found = True

    def inLOS(self, player):
        leftVision: Vector = self.pos - self.leftgen
        rightVision: Vector = self.pos - self.rightgen
        playerVector = self.pos - player.pos

        # Debuging
        # losAngle = (self.leftgen - self.rightgen).angleToX()
        # canvas.draw_line((self.pos+offset).getP(), (self.pos+offset+Vector(1,0).rotateRad(playerVector.angleToX())).getP(), 9, "black")

        if self.length >= playerVector.length():
            if rightVision.angleToX() >= playerVector.angleToX(
            ) >= leftVision.angleToX():
                self.found = True
                self.normalBoundary.color = 'rgb(255,0,0)'
            elif (rightVision.angleToX() < math.pi / 2
                  and leftVision.angleToX() > 3 * math.pi / 2):
                if(rightVision.angleToX()+2*math.pi >= playerVector.angleToX() >= leftVision.angleToX() \
                    or rightVision.angleToX() >= playerVector.angleToX() >= leftVision.angleToX()-2*math.pi):
                    self.found = True
                    self.normalBoundary.color = 'rgb(255,0,0)'
        elif self.length * 2 < playerVector.length(
        ) and self.entity != "flameBat":
            self.found = False

    def updateSoundDistance(self, player):
        if self.soundRange >= (self.pos - player.pos).length():
            self.found = True

    def stop(self, player):
        if (self.radius + player.radius) + self.stopDistance >= (
                self.pos - player.pos).length():
            self.direction = Vector(0, 0)

    def follow(self, player):
        self.losColour = 'rgb(255,0,0)'
        playertest: Vector = player.pos.copy().subtract(self.pos)
        self.direction = playertest

    def search(self, player):
        playerVector = self.pos - player.pos
        vectorOfLeft = self.leftBoundary.pA - self.leftBoundary.pB
        Vectorleft = self.pos.copy().subtract(vectorOfLeft)
        Left = self.pos.copy().subtract(Vectorleft)

        angleLess = Left.getNormal().angle(playerVector.getNormal())
        vectorToNormal = (self.normalBoundary.pA - self.normalBoundary.pB)
        VectorNormal = self.pos.copy().subtract(vectorToNormal)
        normal = self.pos.copy().subtract(VectorNormal)

        tester = playerVector.getNormal().angle(normal.getNormal())

        playerToLOSAngle = (self.pos - player.pos
                            ).angle(self.pos - self.normalGen) * 180 / math.pi
        if playerToLOSAngle < self.rotation * 3:
            rotation = playerToLOSAngle / 7
        else:
            rotation = self.rotation

        if self.found:
            if round(angleLess, 2) > round(tester, 2):
                self.lineLeftGen.rotate(rotation)
                self.normalLine.rotate(rotation)
                self.lineRightGen.rotate(rotation)
            elif round(angleLess, 2) < round(tester, 2):
                self.lineLeftGen.rotate(-rotation)
                self.normalLine.rotate(-rotation)
                self.lineRightGen.rotate(-rotation)
Exemple #17
0
    def start(self, frame, width, height):
        self.sprites = []
        self.walls = []
        self.enemies = []
        self.pickups = []
        self.hearts = []

        self.zoom = 3
        self.mapSize = Vector(4800, 2700)
        self.startPos = Vector(1500, 1900) + Vector(50, 125)

        #Load Images
        image_background = simplegui._load_local_image(
            'Resources/images/map.png')
        image_wall = simplegui._load_local_image('Resources/images/Blank.png')
        image_Bat = simplegui._load_local_image('Resources/images/bat.png')
        image_FireEnemy = simplegui._load_local_image(
            'Resources/images/FireEnemy.png')
        image_laser = simplegui._load_local_image("Resources/images/Laser.png")
        image_teleporter = simplegui._load_local_image(
            'Resources/images/blue_power_up.png')

        #Background
        frame.set_canvas_background("#0170FE")
        self.sprites.append(
            Sprite(self.mapSize / 2, image_background, self.mapSize.getP()))

        #Teleporter
        self.teleporter = Sprite(
            Vector(width * self.zoom / 2, height * self.zoom / 2) +
            Vector(1500, 0), image_teleporter, [150, 150])
        self.sprites.append(self.teleporter)

        #Pickups
        self.pickups.append(
            Pickup(Vector(300, 300), image_laser, 1, 1, "Ability", "Laser"))

        #Enemies
        self.enemies.append(
            FireEnemy(Vector(3240, 1580), "Red", "Sniper", image_FireEnemy,
                      [0, 0], 180))
        self.enemies.append(
            FireEnemy(Vector(2620, 1910), "Red", "Sniper", image_FireEnemy,
                      [0, 1], 270))
        self.enemies.append(
            FireEnemy(Vector(1050, 1640), "Red", "Sniper", image_FireEnemy,
                      [0, 2], 90))
        self.enemies.append(
            Bat(Vector(1200, 950), "Blue", "Melee", image_Bat, [0, 3], 160))
        self.enemies.append(
            Bat(Vector(4040, 1080), "Blue", "Melee", image_Bat, [0, 3], 160))
        self.enemies.append(
            Bat(Vector(3900, 1480), "Blue", "Melee", image_Bat, [0, 1], 260))

        # #All sprites
        # wallWidth = 50
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(470, 1350), image_wall, [100, 1900]))
        # # spriteGroup.append(Sprite(Vector(100,50) , image_wall , [50,50] ))
        # # spriteGroup.append(Sprite(Vector(150,50) , image_wall, [50, 50], math.pi * 45 / 360))
        #
        # spriteGroup2 = SpriteGroup(spriteGroup)
        # spriteGroup2.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(4350, 1350), image_wall, [100, 1900]))
        # # spriteGroup.append(Sprite(Vector(100,50) , image_wall , [50,50] ))
        # # spriteGroup.append(Sprite(Vector(150,50) , image_wall, [50, 50], math.pi * 45 / 360))
        #
        # spriteGroup4 = SpriteGroup(spriteGroup)
        # spriteGroup4.addTo(self.sprites)
        #
        # # spriteGroup = []
        # # for i in range(0,7):
        # #     spriteGroup.append(Sprite( Vector(695,460+wallWidth*i) , image_wall , [50,50] ))
        # # spriteGroup1 = SpriteGroup(spriteGroup)
        # # spriteGroup1.addTo(self.sprites)
        # #
        # spriteGroup = []
        # spriteGroup.append(Sprite( Vector(2400,440) , image_wall , [3900,100] ))
        # spriteGroup3 = SpriteGroup(spriteGroup)
        # spriteGroup3.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(2400, 2250), image_wall, [3900, 100]))
        # spriteGroup5 = SpriteGroup(spriteGroup)
        # spriteGroup5.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(1300, 700), image_wall, [870, 100]))
        # spriteGroup6 = SpriteGroup(spriteGroup)
        # spriteGroup6.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(2300, 620), image_wall, [1200, 80]))
        # spriteGroup9 = SpriteGroup(spriteGroup)
        # spriteGroup9.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(840, 900), image_wall, [80, 500]))
        # spriteGroup7 = SpriteGroup(spriteGroup)
        # spriteGroup7.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(1690, 900), image_wall, [80, 500]))
        # spriteGroup12 = SpriteGroup(spriteGroup)
        # spriteGroup12.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(680, 1200), image_wall, [400, 100]))
        # spriteGroup8 = SpriteGroup(spriteGroup)
        # spriteGroup8.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(1940, 1200), image_wall, [600, 100]))
        # spriteGroup11 = SpriteGroup(spriteGroup)
        # spriteGroup11.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(1380, 1500), image_wall, [1700, 100]))
        # spriteGroup10 = SpriteGroup(spriteGroup)
        # spriteGroup10.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(2240, 1770), image_wall, [1700, 100]))
        # spriteGroup13 = SpriteGroup(spriteGroup)
        # spriteGroup13.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(1500, 2130), image_wall, [2000, 100]))
        # spriteGroup14 = SpriteGroup(spriteGroup)
        # spriteGroup14.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(1430, 1970), image_wall, [80, 300]))
        # spriteGroup15 = SpriteGroup(spriteGroup)
        # spriteGroup15.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(2455, 2050), image_wall, [80, 100]))
        # spriteGroup16 = SpriteGroup(spriteGroup)
        # spriteGroup16.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(3400, 1850), image_wall, [80, 700]))
        # spriteGroup17 = SpriteGroup(spriteGroup)
        # spriteGroup17.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(3400, 850), image_wall, [80, 750]))
        # spriteGroup18 = SpriteGroup(spriteGroup)
        # spriteGroup18.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(2430, 1150), image_wall, [80, 750]))
        # spriteGroup19 = SpriteGroup(spriteGroup)
        # spriteGroup19.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(2890, 900), image_wall, [80, 500]))
        # spriteGroup20 = SpriteGroup(spriteGroup)
        # spriteGroup20.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(2950, 1500), image_wall, [900, 100]))
        # spriteGroup21 = SpriteGroup(spriteGroup)
        # spriteGroup21.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(2550, 1200), image_wall, [300, 100]))
        # spriteGroup26 = SpriteGroup(spriteGroup)
        # spriteGroup26.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(3100, 1200), image_wall, [500, 100]))
        # spriteGroup22 = SpriteGroup(spriteGroup)
        # spriteGroup22.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(3850, 800), image_wall, [800, 100]))
        # spriteGroup23 = SpriteGroup(spriteGroup)
        # spriteGroup23.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(3850, 1900), image_wall, [800, 100]))
        # spriteGroup24 = SpriteGroup(spriteGroup)
        # spriteGroup24.addTo(self.sprites)
        #
        # spriteGroup = []
        # spriteGroup.append(Sprite(Vector(4200, 1400), image_wall, [80, 1000]))
        # spriteGroup25 = SpriteGroup(spriteGroup)
        # spriteGroup25.addTo(self.sprites)

        # spriteGroup = []
        # for i in range(0, 7):
        #     spriteGroup.append(Sprite(Vector(695 + wallWidth * i, 460), image_wall, [50, 50]))
        # spriteGroup3 = SpriteGroup(spriteGroup)
        # spriteGroup3.addTo(self.sprites)
        #
        # spriteGroup = []
        # for i in range(0,7):
        #     spriteGroup.append(Sprite( Vector(695+wallWidth*i,760) , image_wall , [50,50] ))
        # spriteGroup4 = SpriteGroup(spriteGroup)
        # spriteGroup4.addTo(self.sprites)

        #All walls
        lineHalfWidth = 15
Exemple #18
0
 def stop(self, player):
     if (self.radius + player.radius) + self.stopDistance >= (
             self.pos - player.pos).length():
         self.direction = Vector(0, 0)
Exemple #19
0
 def click(self,pos):
     print(Vector(pos[0],pos[1])-offset)
     if inventory.isOpen:
         inventory.select(character)
Exemple #20
0
    def __init__(self,resolution,drawWalls1):
        global frame,pygame,simplegui,drawWalls,fps,pickups

        drawWalls = drawWalls1

        CANVAS_HEIGHT=resolution[1] #900
        CANVAS_WIDTH=resolution[0] #1600
        offset = Vector(0,0)
        mousePos = (0,0)

        #Defining Objects
        character_image = simplegui._load_local_image('Resources/images/player.png')
        self.image_speed = simplegui._load_local_image("Resources/images/speed.png")
        self.image_damage = simplegui._load_local_image("Resources/images/damage.png")
        self.image_stamina = simplegui._load_local_image("Resources/images/stamina.png")
        image_Bat = simplegui._load_local_image('Resources/images/hellBat.png')

        if not globals().__contains__("frame"):
            frame = simplegui.create_frame("Zelda Game", CANVAS_WIDTH, CANVAS_HEIGHT,0)

        keyboard = Keyboard()
        currentMap = 0
        map = [Tutorial(),ManMap(),LynelMap()]
        map[currentMap].start(frame,CANVAS_WIDTH,CANVAS_HEIGHT)
        
        spritesheet = Spritesheet(character_image, 10, 8, 1/10)
        spritesheet.addAnimation([0, 0], [2, 0])
        spritesheet.addAnimation([0, 1], [2, 1])
        spritesheet.addAnimation([0, 2], [0, 2])
        spritesheet.addAnimation([0, 3], [2, 3])
        spritesheet.addAnimation([0, 4], [7, 4])
        spritesheet.addAnimation([0, 5], [7, 5])
        spritesheet.addAnimation([0, 6], [7, 6])
        spritesheet.addAnimation([0, 7], [7, 7])

        global noHearts

        # health = Health(healthOB, noHearts)

        character = Character(Vector(0,0),map[currentMap].startPos,spritesheet,0,(64,64))
        character.healthInit(HealthIMG,heart1)
        character.healthStart(character.healthOB,3)
        offset = -map[currentMap].startPos + (Vector(CANVAS_WIDTH, CANVAS_HEIGHT) / 2)
        interactions = Interactions()
        inventory = Inventory(CANVAS_WIDTH, CANVAS_HEIGHT,character)
        projectiles = []
        lasers = []
        teleporter = map[currentMap].teleporter
        walls = map[currentMap].walls
        enemies = map[currentMap].enemies
        pickups = map[currentMap].pickups
        hearts = map[currentMap].hearts
        boss = None

        trident = simplegui._load_local_image('Resources/images/Trident.png')
        incrementalTimer = 0
        batTimer = 0
        cooldownAbility = 0
        detect = False

        fps = SimpleGUICS2Pygame.simplegui_lib_fps.FPS(x=CANVAS_WIDTH-50, y=10, font_color='Red', font_size=40)
        fps.start()

        # Assign callbacks to event handlers
        frame.set_mouseclick_handler(self.click)
        frame.set_keydown_handler(self.keyDown)
        frame.set_keyup_handler(self.keyUp)
        frame.set_draw_handler(self.draw)
        timer = simplegui.create_timer(300, self.attack)

        globals().update(locals())

        timer.start()
        # Start the frame animation
        frame.start()
Exemple #21
0
    def draw(self,canvas):
        global noHearts,interactions,health,previous,healthList,heart1,frame,keyboard,CANVAS_WIDTH,CANVAS_HEIGHT,healthOB,image_Bat,timer,pygame,frame,simplegui,drawWalls,fps
     #Updating Mouse Position



        mousePos = (pygame.mouse.get_pos()[0]-frame._canvas_x_offset,pygame.mouse.get_pos()[1]-frame._canvas_y_offset)
        global incrementalTimer, cooldownAbility

        if not character.activeAbility.__class__.__name__ == "Laser":
            if cooldownAbility == 0:
                cooldownAbility = 20
                if not inventory.isOpen and pygame.mouse.get_pressed()[0]:
                    character.fire(Vector(mousePos[0], mousePos[1]) - offset, projectiles, lasers)
            cooldownAbility -= 1
        else:
            if not inventory.isOpen and pygame.mouse.get_pressed()[0]:
                character.fire(Vector(mousePos[0], mousePos[1]) - offset, projectiles, lasers)

        i = 0
        while i < enemies.__len__()-1:
            k = enemies.__len__()-1
            while k > i:
                enemies[i].alertDistance(enemies[k])
                k -= 1
            i += 1


        #Interactions
        for wall in walls:
            interactions.playerHitWall(wall,character)
            for projectile in projectiles:
                interactions.bounceBallOffWall(projectile,wall,projectiles)


        interactions.playerTouchTeleporter(teleporter,character,self.nextMap)

        #Drawing and Updates
        map[currentMap].draw(canvas, offset, character, inventory)
        character.draw(canvas,offset)
        character.update(keyboard, map[currentMap].zoom, mousePos, offset,frame,timer)

        canvas.draw_circle(mousePos,10,1,"black","black")
        for enemy in enemies:
            enemy.draw(canvas,offset)
            enemy.update(map[currentMap].zoom, character)
            if enemy.found:
                enemy.follow(character)
                enemy.search(character)
                enemy.stop(character)
            elif not enemy.found:
                enemy.vel = Vector(0,0)


        for pickup in pickups:
            if interactions.playerTouchPickup(pickup, pickups, character, inventory,canvas):
                if character.heartList[character.last] > 1:
                    character.heartList[character.last] = 1
                    character.hearts[character.last - 1].frameIndex = [0, 0]
                elif character.last < character.noHearts:
                    character.last += 1
                    character.heartList[character.last] = 1
                    character.hearts[character.last - 1].frameIndex = [0, 0]
                else:
                    character.noHearts += 1
                    character.healthListInit.append(HealthIMG(Vector(character.previous, 50), heart1))
                    character.previous += 50
                    character.hearts.append(character.healthListInit[character.noHearts - 1])
                    character.heartList.append(1)
                    character.last += 1

        for pickup in pickups:
            pickup.draw(canvas, offset)

        inventory.draw(canvas)
        inventory.update(keyboard, (character.pos + offset).getP(), mousePos)

        #Moving Screen
        View().moveScreen(offset,character.pos,CANVAS_WIDTH,CANVAS_HEIGHT)
        for proj in projectiles:
            proj.draw(canvas,offset)
            proj.update(projectiles, map[currentMap].zoom)
            Interactions().ballHitPlayer(proj,character,projectiles)
            for enemy in enemies:
                interactions.ballHitEnemy(proj,projectiles,enemy,enemies)
            if currentMap == 2:
                interactions.ballHitBoss(proj,projectiles,boss,inventory)

        for laser in lasers:
            if not lasers.count(laser) > 0: continue
            laser.draw(canvas,offset)
            for enemy in enemies:
                interactions.laserHitEnemy(laser,lasers,enemy,enemies)
            if currentMap == 2:
                interactions.laserHitBoss(laser, lasers,boss)
            lasers.pop(lasers.index(laser))

        if drawWalls:
            for wall in walls:
                #To see collision walls
                wall.draw(canvas,offset)



        if currentMap == 2:
            global detect
            if character.pos.x >= 2881 or boss.health != 1000:
                detect = True
                if map[2].trap:
                    map[2].wallPoints2.append((2244, 1112))
                    map[2].wallPoints2.append((2244, 1243))
                    map[2].updateWalls()
                    wall.draw(canvas, offset)
                    map[2].trap = False
            if boss.health <= 0:
                boss.death = True
            if not boss.death and detect:
                global batTimer
                boss.detectionArea(character)
                boss.drawDetectionArea(canvas, offset)
                boss.update()
                if boss.spawn and batTimer % 100 == 0:
                    enemies.append(flameBat(boss.pos + Vector(0, -80), "Blue", "Melee", image_Bat, [0, 0], 160))
                    batTimer = 0
                if boss.health < 700 and boss.health > 500 or boss.health < 200:
                    boss.drawFire(canvas, offset, character, projectiles, lasers)
                batTimer += 1
            boss.updateSprite(canvas, offset, character)


        #Draw HUD
        fps.draw_fct(canvas)
        for i in range(0,character.noHearts):
            character.healthOB[i].draw(canvas, offset)

        canvas.draw_line((20, 100), (175, 100), 30, "white")
        canvas.draw_line((25, 100), (170, 100), 25, "black")
        canvas.draw_line((25, 100), (170-character.stamina, 100), 25, character.staminaColor)

        canvas.draw_image(self.image_damage, (self.image_damage.get_width() / 2, self.image_damage.get_height() / 2), (self.image_damage.get_width(), self.image_damage.get_height()), (40, 150), (50, 50))
        if character.damageStack > 0:
            canvas.draw_text(("x" + str(character.damageStack)), [50,160], 20, "white")

        canvas.draw_image(self.image_speed, (self.image_speed.get_width() / 2, self.image_speed.get_height() / 2),
                          (self.image_speed.get_width(), self.image_speed.get_height()), (90, 150), (50, 50))
        if character.speedStack > 0:
            canvas.draw_text(("x" + str(character.speedStack)), [100, 160], 20, "white")

        canvas.draw_image(self.image_stamina, (self.image_stamina.get_width() / 2, self.image_stamina.get_height() / 2),
                          (self.image_stamina.get_width(), self.image_stamina.get_height()), (140, 150), (50, 50))
        if character.staminaStack > 0:
            canvas.draw_text(("x" + str(character.staminaStack)), [150, 160], 20, "white")
Exemple #22
0
    def start(self, frame, width, height):
        self.sprites = []
        self.walls = []
        self.enemies = []
        self.pickups = []
        self.hearts = []
        self.zoom = 3
        self.mapSize = Vector(4800, 2700)
        self.startPos = Vector(300, 450)

        #Load Images
        image_background = simplegui._load_local_image(
            'Resources/images/cal.png')
        image_Bat = simplegui._load_local_image('Resources/images/bat.png')
        image_FireEnemy = simplegui._load_local_image(
            'Resources/images/FireEnemy.png')
        image_laser = simplegui._load_local_image("Resources/images/Laser.png")
        image_teleporter = simplegui._load_local_image(
            'Resources/images/blue_power_up.png')
        image_CannonMob = simplegui._load_local_image(
            'Resources/images/CannonMob.png')
        image_speed = simplegui._load_local_image("Resources/images/speed.png")
        image_damage = simplegui._load_local_image(
            "Resources/images/damage.png")
        image_stamina = simplegui._load_local_image(
            "Resources/images/stamina.png")
        image_shotgun = simplegui._load_local_image(
            "Resources/images/Shotgun.png")
        hearts = simplegui._load_local_image(
            "Resources/images/heartsprite.png")
        heartcontainers = simplegui._load_local_image(
            "Resources/images/heartcontainerSprite.png")

        #Background
        frame.set_canvas_background("#0170FE")
        self.sprites.append(
            Sprite(self.mapSize / 2, image_background, self.mapSize.getP()))

        #Teleporter
        self.teleporter = Sprite(Vector(274, 2100), image_teleporter,
                                 [150, 150])
        self.sprites.append(self.teleporter)

        #Pickups
        #Side Area
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(-50, 500), image_laser,
                1, 1, "Ability", "Laser"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1450, -300),
                image_speed, 1, 1, "powerup", "speed"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1450, -150),
                image_damage, 1, 1, "powerup", "damage"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1450, 0), image_speed,
                1, 1, "powerup", "speed"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(2800, -300),
                image_damage, 1, 1, "powerup", "damage"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(2800, -150),
                image_speed, 1, 1, "powerup", "speed"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(2800, 0), image_damage,
                1, 1, "powerup", "damage"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(2800, 150), hearts, 4,
                1, "powerup", "heart", True))

        #Pathway
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(-460, 1300),
                image_shotgun, 1, 1, "Ability", "Shotgun"))

        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(115, -250),
                image_stamina, 1, 1, "powerup", "stamina"))

        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(900, -155),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(950, -155),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1000, -155),
                image_stamina, 1, 1, "powerup", "stamina"))

        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(2100, -50),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(2100, -200),
                image_stamina, 1, 1, "powerup", "stamina"))

        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1900, 450),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1700, 450),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1400, 450),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1200, 450),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1000, 450),
                image_stamina, 1, 1, "powerup", "stamina"))

        #Pathway2
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1100, 1150),
                image_speed, 1, 1, "powerup", "speed"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1150, 1150),
                image_damage, 1, 1, "powerup", "damage"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1200, 1150), hearts, 4,
                1, "powerup", "heart", True))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1250, 1150),
                image_speed, 1, 1, "powerup", "speed"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1300, 1150),
                image_damage, 1, 1, "powerup", "damage"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(1350, 1150), hearts, 4,
                1, "powerup", "heart", True))

        #Enemies
        #Beginning
        self.enemies.append(
            FireEnemy(Vector(640, 110), "Red", "Sniper", image_FireEnemy,
                      [0, 1], 230))
        self.enemies.append(
            CannonMob(
                Vector(width / 2, height / 2) + Vector(400, 10), "Blue",
                "Sniper", image_CannonMob, [0, 0], 0))
        #Side Area
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(1600, -300), "Red",
                "Sniper", image_FireEnemy, [0, 1], 95))
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(1600, -150), "Red",
                "Sniper", image_FireEnemy, [0, 1], 100))
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(1600, 0), "Red",
                "Sniper", image_FireEnemy, [0, 2], 60))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(2600, -300), "Blue",
                "Melee", image_Bat, [0, 3], 250))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(2600, -150), "Blue",
                "Melee", image_Bat, [0, 3], 280))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(2600, 0), "Blue",
                "Melee", image_Bat, [0, 1], 275))
        #Guarding Laser
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(100, 375), "Blue",
                "Melee", image_Bat, [0, 3], 100))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(100, 475), "Blue",
                "Melee", image_Bat, [0, 3], 80))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(100, 575), "Blue",
                "Melee", image_Bat, [0, 1], 90))
        #Pathwaysprites
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(-50, 750), "Red",
                "Sniper", image_FireEnemy, [0, 2], 120))
        self.enemies.append(
            Bat(Vector(4040, 1080), "Blue", "Melee", image_Bat, [0, 3], 160))
        self.enemies.append(
            Bat(Vector(3900, 1420), "Blue", "Melee", image_Bat, [0, 1], 260))
        #Pathway2
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(-200, 1150), "Red",
                "Sniper", image_FireEnemy, [0, 1], 270))
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(100, 1150), "Red",
                "Sniper", image_FireEnemy, [0, 2], 250))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(1000, 1150), "Blue",
                "Melee", image_Bat, [0, 3], 120))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(1500, 1150), "Blue",
                "Melee", image_Bat, [0, 1], 200))
        self.enemies.append(
            FireEnemy(Vector(2620, 1810), "Red", "Sniper", image_FireEnemy,
                      [0, 1], 270))

        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(1800, 1650), "Red",
                "Sniper", image_FireEnemy, [0, 1], 180))
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(2000, 1650), "Red",
                "Sniper", image_FireEnemy, [0, 1], 180))
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(2200, 1650), "Red",
                "Sniper", image_FireEnemy, [0, 1], 180))
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(2400, 1650), "Red",
                "Sniper", image_FireEnemy, [0, 1], 180))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(1550, 2050), "Blue",
                "Melee", image_Bat, [0, 3], 0))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(1650, 2050), "Blue",
                "Melee", image_Bat, [0, 1], 0))

        #Walls
        wallWidth = 50
        lineHalfWidth = 8
        wallPoints1 = [(90, 70), (4740, 70), (4740, 2630), (90, 2630),
                       (90, 70)]
        wallPoints2 = [(90, 670), (570, 670), (570, 290), (650, 290),
                       (650, 320), (1130, 320), (1130, 725), (4170, 725)]
        wallPoints3 = [(1638, 154), (1638, 379), (1855, 379), (1855, 154),
                       (1638, 154)]
        wallPoints4 = [(2169, 72), (2169, 537), (2809, 537)]
        wallPoints5 = [(3039, 518), (3770, 518), (3770, 71)]
        wallPoints6 = [(3770, 501), (4587, 501), (4587, 1328), (395, 1328),
                       (395, 1474), (4160, 1474), (4160, 1705), (3001, 1712)]
        wallPoints7 = [(4086, 834), (4086, 1080), (2992, 1080), (2992, 834),
                       (4086, 834)]
        wallPoints8 = [(2913, 737), (2913, 1100), (1783, 1100)]
        wallPoints9 = [(1485, 1095), (636, 1095), (636, 752), (1116, 752)]
        wallPoints10 = [(634, 1095), (296, 1095), (296, 949), (92, 949)]
        wallPoints11 = [(1638, 1694), (2737, 1694)]
        wallPoints12 = [(89, 1937), (4091, 1937)]
        wallPoints13 = [(4159, 1706), (4313, 1706), (4313, 2510), (85, 2510)]
        wallPoints14 = [(983, 2329), (2080, 2329)]
        wallPoints15 = [(2558, 2329), (4068, 2329)]
        wallPoints16 = [(1983, 310), (2115, 310), (2115, 427), (1983, 427),
                        (1983, 310)]
        wallPoints17 = [(1517, 310), (1377, 310), (1377, 430), (1517, 430),
                        (1517, 310)]

        wallPoints = [
            wallPoints1, wallPoints2, wallPoints3, wallPoints4, wallPoints5,
            wallPoints6, wallPoints7, wallPoints8, wallPoints9, wallPoints10,
            wallPoints11, wallPoints12, wallPoints13, wallPoints14,
            wallPoints15, wallPoints16, wallPoints17
        ]
        for wallPoint in wallPoints:
            for i in range(wallPoint.__len__() - 1):
                pos1 = Vector(wallPoint[i][0], wallPoint[i][1])
                pos2 = Vector(wallPoint[i + 1][0], wallPoint[i + 1][1])
                self.walls.append(Wall(lineHalfWidth, pos1, pos2))
Exemple #23
0
    def start(self, frame, width, height):
        self.width = width
        self.height = height

        self.sprites = []
        self.walls = []
        self.enemies = []
        self.pickups = []
        self.hearts = []
        self.zoom = 3
        self.mapSize = Vector(width * self.zoom, height * self.zoom)
        self.startPos = Vector(width / 2 - 1200, height / 2)

        self.changedAbility = False

        #Load Images
        image_wall = simplegui._load_local_image('Resources/images/wall1.png')
        image_wall2 = simplegui._load_local_image('Resources/images/wall2.png')
        image_teleporter = simplegui._load_local_image(
            'Resources/images/blue_power_up.png')
        image_Bat = simplegui._load_local_image('Resources/images/bat.png')
        image_FireEnemy = simplegui._load_local_image(
            'Resources/images/FireEnemy.png')
        image_laser = simplegui._load_local_image("Resources/images/Laser.png")
        image_speed = simplegui._load_local_image("Resources/images/speed.png")
        image_damage = simplegui._load_local_image(
            "Resources/images/damage.png")
        image_stamina = simplegui._load_local_image(
            "Resources/images/stamina.png")
        image_shotgun = simplegui._load_local_image(
            "Resources/images/Shotgun.png")
        hearts = simplegui._load_local_image(
            "Resources/images/heartsprite.png")

        #Background
        frame.set_canvas_background("#c5ccd8")

        #Pickups
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(-1200, -200),
                image_shotgun, 1, 1, "Ability", "Shotgun"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(-1200, 200),
                image_shotgun, 1, 1, "Ability", "Shotgun"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(500, 0), image_laser, 1,
                1, "Ability", "Laser"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(600, -225), image_speed,
                1, 1, "powerup", "speed"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(700, -225),
                image_damage, 1, 1, "powerup", "damage"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(600, 200),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(650, 200),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(700, 200),
                image_stamina, 1, 1, "powerup", "stamina"))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(-250, 200), hearts, 4,
                1, "powerup", "heart", True))
        self.pickups.append(
            Pickup(
                Vector(width / 2, height / 2) + Vector(-250, -250), hearts, 4,
                1, "powerup", "heart", True))

        #Enemies
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(400, 0), "Red",
                "Sniper", image_FireEnemy, [0, 0], 270))
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(300, 250), "Red",
                "Sniper", image_FireEnemy, [0, 1], 300))
        self.enemies.append(
            FireEnemy(
                Vector(width / 2, height / 2) + Vector(300, -250), "Red",
                "Sniper", image_FireEnemy, [0, 2], 240))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(-600, 0), "Blue",
                "Melee", image_Bat, [0, 3], 270))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(1100, 0), "Blue",
                "Melee", image_Bat, [0, 3], 270))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(1100, 150), "Blue",
                "Melee", image_Bat, [0, 3], 270))
        self.enemies.append(
            Bat(
                Vector(width / 2, height / 2) + Vector(1100, -150), "Blue",
                "Melee", image_Bat, [0, 1], 270))

        #All sprites
        wallWidth = 100
        borderLength = 4

        self.teleporter = Sprite(
            Vector(width / 2, height / 2) + Vector(1350, 0), image_teleporter,
            [150, 150])
        self.sprites.append(self.teleporter)

        #Border Walls
        spriteGroup = []
        for i in range(0, borderLength * 2 * 4 + 1):
            spriteGroup.append(
                Sprite(
                    Vector(width / 2, height / 2) +
                    Vector(-wallWidth * borderLength * 4 + wallWidth * i,
                           wallWidth * borderLength), image_wall, [100, 100]))
        spriteGroup1 = SpriteGroup(spriteGroup)
        spriteGroup1.addTo(self.sprites)
        spriteGroup = []
        for i in range(0, borderLength * 2 * 4 + 1):
            spriteGroup.append(
                Sprite(
                    Vector(width / 2, height / 2) +
                    Vector(-wallWidth * borderLength * 4 + wallWidth * i,
                           -wallWidth * borderLength), image_wall, [100, 100]))
        spriteGroup2 = SpriteGroup(spriteGroup)
        spriteGroup2.addTo(self.sprites)
        spriteGroup = []
        for i in range(0, borderLength * 2 + 1):
            spriteGroup.append(
                Sprite(
                    Vector(width / 2, height / 2) +
                    Vector(wallWidth * borderLength * 4,
                           -wallWidth * borderLength + wallWidth * i),
                    image_wall, [100, 100]))
        spriteGroup3 = SpriteGroup(spriteGroup)
        spriteGroup3.addTo(self.sprites)
        spriteGroup = []
        for i in range(0, borderLength * 2 + 1):
            spriteGroup.append(
                Sprite(
                    Vector(width / 2, height / 2) +
                    Vector(-wallWidth * borderLength * 4,
                           -wallWidth * borderLength + wallWidth * i),
                    image_wall, [100, 100]))
        spriteGroup4 = SpriteGroup(spriteGroup)
        spriteGroup4.addTo(self.sprites)

        wallWidth = 50
        wallLength = 5
        # spriteGroup = []
        # for i in range(0, wallLength*2 +1):
        #     spriteGroup.append(Sprite(Vector(width / 2-375, height / 2) + Vector(-wallWidth*wallLength + wallWidth * i, -wallWidth*wallLength), image_wall2, [50, 50]))
        # spriteGroup5 = SpriteGroup(spriteGroup)
        # spriteGroup5.addTo(self.sprites)
        # spriteGroup = []
        # for i in range(0, wallLength*2 +1):
        #     spriteGroup.append(Sprite(Vector(width / 2-375, height / 2) + Vector(-wallWidth*wallLength + wallWidth * i, wallWidth*wallLength), image_wall2, [50, 50]))
        # spriteGroup6 = SpriteGroup(spriteGroup)
        # spriteGroup6.addTo(self.sprites)

        #All walls
        lineHalfWidth = 12
        WallBox(lineHalfWidth, spriteGroup1).addTo(self.walls)
        WallBox(lineHalfWidth, spriteGroup2).addTo(self.walls)
        WallBox(lineHalfWidth, spriteGroup3).addTo(self.walls)
        WallBox(lineHalfWidth, spriteGroup4).addTo(self.walls)