Example #1
0
    def __init__(self, x, y, width, height, frames):
        self.frames = frames
        image = frames[0]
        PhysicsBody.__init__(self, x, y, width, height, image)
        self.bounds = pygame.sprite.Group()
        self.changeDirection = False
        self.angle = 0

        self.hspeed = choice([-3, -2, 2, 3])
        self.index = 0
        self.frame = 0
Example #2
0
    def __init__(self, x, y, width, height, image):
        PhysicsBody.__init__(self, x, y, width, height, image)
        self.image.set_colorkey(COLOR.black)
        self.frameNumber = 0
        self.speed = 3
        self.timeout = 0
        self.captured = False
        self.safe = False
        self.givePoint = False
        self.id = 0
        self.killer_group = pygame.sprite.Group()
        self.storage_group = pygame.sprite.Group()

        self.dead_sound = mixer.Sound(os.path.join("assets", "sfx", "data_explode.wav"))
        self.point_sound = mixer.Sound(os.path.join("assets", "sfx", "sfx_zap.ogg"))
        self.dead_sound.set_volume(0.4)
        self.point_sound.set_volume(0.5)
Example #3
0
    def __init__(self, x, y , width, height, animationFrames, id):
        mixer.init()
        image = animationFrames
        PhysicsBody.__init__(self, x, y, width, height, image)
        self.jumpHeight = PLAYER.jump
        self.speed = PLAYER.speed
        self.has_data = False
        self.shoot_data = False
        self.direction = DIRECTION.left
        self.id = id
        self.hurt = False
        self.dead = False
        self.cooldown = 0
        self.frozen = False
        self.respawn = False
        self.reconstruct = False
        self.reconstruction_timer = 2.5
        self.blink_timer = 0
        self.label = PhysicsBody(0, 0, 17, 12, PLAYER.p1_label)
        self.glow = PhysicsBody(0, 0, 48, 48, ASSET.player1_glow)
        self.blink = PhysicsBody(0, 0, 32, 32, ASSET.player_hurt)
        self.original_image = self.image
        self.danger_group = pygame.sprite.Group()
        self.particle_group = pygame.sprite.Group()
        
        self.sort_players()
        self.update_label()
        self.original_glow_image = self.glow.image
        self.original_blink_image = self.blink.image
        self.respawn_position = x, y
        self.death_pos = self.rect.centerx, self.rect.centery

        self.controller1 = self.get_controller(1)
        self.controller2 = self.get_controller(2)

        self.dead_sound = mixer.Sound(os.path.join("assets", "sfx", "sfx_lose.ogg"))
        self.dead_sound.set_volume(0.5)
        self.consume_sound = mixer.Sound(os.path.join("assets", "sfx", "sfx_shieldUp.ogg"))
        self.consume_sound.set_volume(0.3)
        self.throw_sound = mixer.Sound(os.path.join("assets", "sfx", "sfx_shieldDown.ogg"))
        self.throw_sound.set_volume(0.3)
Example #4
0
    def create_level(self):
        blockImage = ASSET.blockImage

        for block in self.blocks:
            if block[2] != 0:
                levelBlock = PhysicsBody(0, 0, self.data.tilewidth, self.data.tileheight, blockImage)
                levelBlock.image = levelBlock.image.convert_alpha()
                levelBlock.rect.x = self.data.tilewidth * block[0]
                levelBlock.rect.y = self.data.tileheight * block[1]
                self.player1.collision_group.add(levelBlock)
                self.player2.collision_group.add(levelBlock)
                self.display_group.add(levelBlock)
                self.block_group.add(levelBlock)

        for dataorb in self.datafragments:
            self.fragmentWidth = dataorb.width
            self.fragmentHeight = dataorb.height

        for vport in self.dataspawner:
            io_port = PhysicsBody(vport.x, vport.y, vport.width, vport.height, ASSET.ioInImage)
            io_port.hspeed = 4
            self.dataspawner_group.add(io_port)
            self.display_group.add(io_port)
            self.fragmentSpawnPos = [vport.x + vport.width/2, vport.y + vport.height]

        for port in self.portals:
            portal_base = PhysicsBody(port.x, port.y, port.width, port.height, ASSET.portal_base, "left")
            if portal_base.rect.centerx < SCREEN.width/2:
                portal = PhysicsBody(0, 0, 60, 55, ASSET.p1_portal, "left")
            else:
                portal = PhysicsBody(0, 0, 60, 55, ASSET.p2_portal, "left")
            portal.rect.centerx = portal_base.rect.centerx
            portal.rect.bottom = portal_base.rect.top
            self.portals_group.add(portal_base)
            self.display_group.add(portal_base)
            self.display_group.add(portal)

        for bound in self.bounds:
            saw_bound = PhysicsBody(bound.x, bound.y, bound.width, bound.height, blockImage)
            self.bounds_group.add(saw_bound)

        for saw in self.saws:
            sawblade = Saw(saw.x, saw.y, saw.width, saw.height, ASSET.sawFrames)
            sawblade.bounds = self.bounds_group.copy()
            self.saw_group.add(sawblade)
            self.display_group.add(sawblade)
            tempgroup = self.display_group.copy()
            self.display_group.empty()
            self.display_group.add(sawblade)
            self.display_group.add(tempgroup)
            self.player1.danger_group.add(self.saw_group)
            self.player2.danger_group.add(self.saw_group)

        for fragment in self.datafragment_group:
            fragment.killer_group = self.enemy_group.copy()
            fragment.storage_group.add(self.portals_group)
            fragment.collision_group.add(self.dataspawner_group)
            fragment.killer_group.add(self.saw_group)

        self.player1.collision_group.add(self.portals_group)
        self.player2.collision_group.add(self.portals_group)
        self.player_group.add(self.player1)
        self.player_group.add(self.player1.label)
        self.player_group.add(self.player1.glow)
        self.player_group.add(self.player2)
        self.player_group.add(self.player2.label)
        self.player_group.add(self.player2.glow)
Example #5
0
    def __init__(self, x, y, width, height, frames):
        image = frames.get_walk_frames()[0]
        PhysicsBody.__init__(self, x, y, width, height, image)

        self.hspeed = choice([-1, 1])
Example #6
0
 def __init__(self, x, y, width, height, image):
     PhysicsBody.__init__(self, x, y, width, height, image)