Example #1
0
    def test_check_if_hand_contains_belots_works_with_not_matching_belots_and_contract(
            self):
        player = Player()
        player.check_if_hand_contains_belots(['Qs', 'Ks'], 'Hearts')

        self.assertEqual(player.points, 0)
        self.assertEqual(player.belots, [])
Example #2
0
    def test_if_best_declaration_works_correctly_when_there_are_announcements_of_the_same_type(
            self):
        player = Player()
        player.set_hand((['10c', 'Jc', 'Qc', 'Kc', 'Jh', 'Qh', 'Kh', 'Ah']))
        res = ['Jh', 'Qh', 'Kh', 'Ah']

        self.assertEqual(res, player.best_announcement())
Example #3
0
    def test_check_if_hand_has_zero_belots(self):
        pl = Player()
        pl.check_if_hand_contains_belots(
            ['7s', '8d', '9s', '10c', 'Qd', 'Qh', 'As', 'Ah'], 'All Trumps')

        self.assertEqual(pl.points, 0)
        self.assertEqual(pl.belots, [])
Example #4
0
def worldLoop(window):
    # Add room, player, and npc to world
    room = Room.loadRoom('great_hall')

    player = Player(0, 'TerminusSTC', 100, 100, 'Slytherin', room, (12, 9))
    h_student = NPC(1, 'student', room, (12,12))

    # Setup curses
    curses.noecho()
    curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
    curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(5, curses.COLOR_BLUE, curses.COLOR_BLACK)

    log_strs = list()
    while True:
        input_box = renderMainView(window, room, player, log_strs)
        cmd_input = input_box.edit()

        log_strs.append(cmd_input)
        split_input = cmd_input.split()
        spell, spell_args = split_input[0], split_input[1:]
        player.castSpell(spell, spell_args=spell_args)

        time.sleep(1.0)
Example #5
0
    def __load_entities(self):
        self.ball = Ball(
            position=(SCREEN_WIDTH / 2 - 15, CENTER_HEIGHT - 15)
        )

        self.players = {
            "player_1": Player(
                keys={
                    "up": K_UP,
                    "down": K_DOWN,
                },
                position=(SCREEN_WIDTH - 20, CENTER_HEIGHT - 70),
                size=player_size
            ),
            "player_2": Player(
                keys={
                    "up": K_w,
                    "down": K_s,
                },
                position=(10, CENTER_HEIGHT - 70),
                size=player_size
            )
        }

        self.entities = [
            self.players["player_1"],
            self.players["player_2"],
            self.ball,
        ]
Example #6
0
 def setUp(self):
     pygame.init()
     self.bullets = pygame.sprite.Group()
     self.sprites = pygame.sprite.Group()
     self.screen = pygame.display.set_mode((0, 0))
     self.player = Player(self.sprites, self.bullets)
     self.player_copy = Player(self.sprites, self.bullets)
Example #7
0
    def test_if_get_announcements_works_correctly_when_there_are_announcements_of_same_type(
            self):
        player = Player()
        player.set_hand(['10c', 'Jc', 'Qc', 'Jh', 'Qh', 'Kh'], 'All Trumps')
        res = ['belot', 'triece', 'triece']

        self.assertEqual(res, player.get_announcements())
Example #8
0
 def __create_default_game_state(self, score_rule: ScoreRule) -> GameState:
     empty_scheme = None
     player1 = Player(1, empty_scheme, ControllerType.player.value)
     player2 = Player(2, empty_scheme, ControllerType.player.value)
     return GameState(size=Point(10, 10),
                      initial_position=InitialPosition.empty,
                      score_rule=score_rule,
                      players=(player1, player2))
Example #9
0
    def test_if_check_if_hand_contains_trieces_works_correctly_when_there_is_a_triece(
            self):
        player = Player()
        res = player.check_if_hand_contains_trieces({'10c', 'Jc', 'Qc'})
        exp = set()

        self.assertEqual(res, exp)
        self.assertEqual(player.trieces, [['10c', 'Jc', 'Qc']])
Example #10
0
    def test_if_check_if_hand_contains_trieces_works_correctly_when_there_is_not_triece(
            self):
        player = Player()
        res = player.check_if_hand_contains_trieces({'10c', 'Jc', 'Qh', 'Kh'})
        exp = {'10c', 'Jc', 'Qh', 'Kh'}

        self.assertEqual(res, exp)
        self.assertEqual(player.trieces, [])
    def test_if_constructor_sets_attributes_correctly(self):
        player1 = Player(name='Marto')
        player2 = Player(name='Rado')
        team = Team(player1=player1, player2=player2)

        self.assertEqual(team.team_name, 'Team')
        self.assertIs(player1, team.player1)
        self.assertIs(player2, team.player2)
Example #12
0
    def test_check_if_hand_contains_multiple_belots_and_contract_covers_only_one(
            self):
        player = Player()
        player.check_if_hand_contains_belots(['Qs', 'Ks', 'Qh', 'Kh'],
                                             'Hearts')

        self.assertEqual(player.points, 20)
        self.assertEqual(player.belots, [['Qh', 'Kh']])
Example #13
0
    def test_check_if_hand_contains_multiple_belots_and_contract_is_All_Trumps(
            self):
        player = Player()
        player.check_if_hand_contains_belots(['Qs', 'Ks', 'Qh', 'Kh'],
                                             'All Trumps')

        self.assertEqual(player.points, 40)
        self.assertEqual(player.belots, [['Qs', 'Ks'], ['Qh', 'Kh']])
class GameStateManager():
    def __init__(self):
        pygame.init()
        pygame.display.set_mode([WIDTH, HEIGHT])
        pygame.display.set_caption("Pygame Tilebased RPG")
        pygame.key.set_repeat(100)
        self.SURFACE = pygame.display.get_surface()
        self.current_state = HUMS_STATE
        self.input_handler = InputHandler()
        self.camera = Camera(32, 24)
        self.states = self.create_states()
        self.player = Player(self, 18, 18, 100, 5, 5)
        self.walls = self.states[self.current_state].walls
        self.doors = self.states[self.current_state].doors
        self.npcs = self.states[self.current_state].npcs

    def update(self):
        self.draw_grid()
        self.draw_map()
        self.player.update()
        #self.player.draw(self.camera.apply(self.player))
        self.player.draw()
        self.camera.update(self.player)

    def change_state(self, state):
        self.current_state = state
        self.walls = self.states[self.current_state].walls
        self.doors = self.states[self.current_state].doors
        self.npcs = self.states[self.current_state].npcs

    def create_states(self):
        states = [None] * NUM_STATES
        states[HUMS_STATE] = HumsState(self)
        states[HUMS_INN_STATE] = HumsInnState(self)
        return states

    def draw_grid(self):
        for x in range(0, WIDTH, TILESIZE):
            pygame.draw.line(pygame.display.get_surface(), BLACK, (x, 0),
                             (x, HEIGHT))

        for y in range(0, HEIGHT, TILESIZE):
            pygame.draw.line(pygame.display.get_surface(), BLACK, (0, y),
                             (WIDTH, y))

    def draw_map(self):
        for x in range(len(self.walls)):
            self.walls[x].update()
            self.walls[x].draw(RED)
        for x in range(len(self.doors)):
            self.doors[x].update()
            self.doors[x].draw(BLUE)
        for x in range(len(self.npcs)):
            self.npcs[x].update()
            self.npcs[x].draw()

    def clear_screen(self):
        pygame.display.get_surface().fill((255, 255, 255))
Example #15
0
    def test_check_if_hand_contains_carre_works_with_zero_carre(self):
        pl = Player()
        res = pl.check_if_hand_contains_carres(
            {'8s', '9c', '10d', 'Jh', 'Qs', 'Kh', 'Ac', 'Ad'})
        exp = {'8s', '9c', '10d', 'Jh', 'Qs', 'Kh', 'Ac', 'Ad'}

        self.assertEqual(res, exp)
        self.assertEqual(pl.points, 0)
        self.assertEqual(pl.carres, [])
Example #16
0
    def test_if_check_if_hand_contains_quintes_works_correctly_when_there_is_no_quinte(
            self):
        player = Player()
        res = player.check_if_hand_contains_quintes(
            {'10h', 'Jh', 'Qc', 'Kc', 'As'})
        exp = {'10h', 'Jh', 'Qc', 'Kc', 'As'}

        self.assertEqual(res, exp)
        self.assertEqual(player.quintes, [])
Example #17
0
    def test_if_check_if_hand_contains_quintes_works_correctly_when_there_is_a_quinte(
            self):
        player = Player()
        res = player.check_if_hand_contains_quintes(
            {'10h', 'Jh', 'Qh', 'Kh', 'Ah'})
        exp = set()

        self.assertEqual(res, exp)
        self.assertEqual(player.quintes, [['10h', 'Jh', 'Qh', 'Kh', 'Ah']])
Example #18
0
    def __init__(self, screen):
        self.screen = screen

        self.player = Player(192, 32768)
        self.menu = None
        self.controls = None
        self.state = None

        self.startMenu()
Example #19
0
    def test_check_if_hand_contains_carre_finds_low_carre_and_adds_points(
            self):
        player = Player()
        res = player.check_if_hand_contains_carres(
            {'7s', '8d', 'Qs', 'Qc', 'Qd', 'Qh', 'As', 'Ah'})

        exp = {'7s', '8d', 'As', 'Ah'}

        self.assertEqual(res, exp)
        self.assertEqual(player.points, 100)
        self.assertEqual(player.carres, [['Qs', 'Qc', 'Qd', 'Qh']])
Example #20
0
    def test_if_check_if_hand_contains_quartes_works_correctly_when_there_are_multiple_quartes(
            self):
        player = Player()
        res = player.check_if_hand_contains_quartes(
            {'10c', 'Jc', 'Qc', 'Kc', '10h', 'Jh', 'Qh', 'Kh'})
        exp = set()

        self.assertEqual(res, exp)
        self.assertEqual(
            player.quartes,
            [['10c', 'Jc', 'Qc', 'Kc'], ['10h', 'Jh', 'Qh', 'Kh']])
Example #21
0
    def __init__(self, size=5):
        '''
        A constructor for game. Creates the player and neighborhood and stores
        information regarding them.

        :param size: The size of the neighborhood. (Defaults to 5x5)
        '''
        self.player = Player()
        self.player.add_observer(self)
        self.playerLoc = (0, 0)
        self.neighborhood = Neighborhood(size, size)
        self.isPlaying = True
Example #22
0
    def test_if_constructor_sets_attributes_correctly(self):
        player1 = Player(name='Marto')
        player2 = Player(name='Rado')
        team1 = Team(player1=player1, player2=player2)
        player3 = Player(name='Gosho')
        player4 = Player(name='Pesho')
        team2 = Team(player1=player1, player2=player2)
        r = Round(round_id=1, team1=team1, team2=team2)

        self.assertEqual(r.round_id, 'round 1')
        self.assertEqual(r.team1, team1)
        self.assertEqual(r.team2, team2)
Example #23
0
    def test_check_if_hand_contains_carre_finds_two_highest_carre_and_adds_points(
            self):
        pl = Player()

        res = pl.check_if_hand_contains_carres(
            {'9s', '9c', '9d', '9h', 'Js', 'Jh', 'Jc', 'Jd'})
        exp = set()

        self.assertEqual(res, exp)
        self.assertEqual(pl.points, 350)
        self.assertEqual(pl.carres,
                         [['9s', '9c', '9d', '9h'], ['Js', 'Jc', 'Jd', 'Jh']])
    def test_if_constructor_sets_attributes_correctly(self):
        player1 = Player(name='Marto')
        player2 = Player(name='Rado')
        team1 = Team(team_name='Mechetata', player1=player1, player2=player2)

        player3 = Player(name='Gosho')
        player4 = Player(name='Pesho')
        team2 = Team(team_name='Kotetata', player1=player3, player2=player4)
        g = Game(game_id=1, team1=team1, team2=team2)

        self.assertEqual(g.game_id, 'game 1')
        self.assertEqual(g.team1, team1)
        self.assertEqual(g.team2, team2)
class TestEntities(unittest.TestCase):
    def setUp(self):
        self.player = Player("Socrates O. Rockefeller")
        self.enemy = Mob("Steve")

    def test_player_created(self):
        """Test a player can be created"""
        self.assertTrue(isinstance(self.player, Entity))
        self.assertTrue(isinstance(self.player, Player))

    def test_mob_created(self):
        """Test that a mob can be created"""
        self.assertTrue(isinstance(self.enemy, Entity))
        self.assertTrue(isinstance(self.enemy, Mob))

    def test_player_attack(self):
        """Test that a player attack removes health of the enemy"""
        self.assertEqual(self.enemy.stats["HP"], 10)
        self.player.attack(self.enemy)
        self.assertNotEqual(self.enemy.stats["HP"], 10)

    def test_player_heal(self):
        self.player.stats["HP"] = 2
        self.player.heal(8)
        self.assertEqual(self.player.stats["HP"], 10)

    def test_life(self):
        self.assertTrue(self.player.is_alive())
        self.assertFalse(self.player.is_dead())
        self.player.stats["HP"] = 0
        self.assertTrue(self.player.is_dead())
        self.assertFalse(self.player.is_alive())
 def __init__(self):
     pygame.init()
     pygame.display.set_mode([WIDTH, HEIGHT])
     pygame.display.set_caption("Pygame Tilebased RPG")
     pygame.key.set_repeat(100)
     self.SURFACE = pygame.display.get_surface()
     self.current_state = HUMS_STATE
     self.input_handler = InputHandler()
     self.camera = Camera(32, 24)
     self.states = self.create_states()
     self.player = Player(self, 18, 18, 100, 5, 5)
     self.walls = self.states[self.current_state].walls
     self.doors = self.states[self.current_state].doors
     self.npcs = self.states[self.current_state].npcs
Example #27
0
def main():
    player1 = Player(name='Marto')
    player2 = Player(name='Rado')
    team1 = Team(team_name='Mechetata', player1=player1, player2=player2)

    player3 = Player(name='Gosho')
    player4 = Player(name='Pesho')
    team2 = Team(team_name='Kotetata', player1=player3, player2=player4)
    w = WriteToTxt(team1, team2)
    g1 = Game(game_id=1, team1=team1, team2=team2, write_to_txt=w)
    g1.play_game()
    g1.to_json()
    g2 = Game(game_id=2, team1=team1, team2=team2, write_to_txt=w)
    g2.play_game()
    g2.to_json()
Example #28
0
def start(screen: pygame.surface.Surface):
    is_game_open = True
    clock = pygame.time.Clock()  # Часы

    # Игрок
    player = Player(screen.get_width() * 0.5, screen.get_height() * 0.5)
    # Группа со спрайтами игрока и его приуела
    player_sprites = pygame.sprite.Group()
    player_sprites.add(player)
    player_sprites.add(player.scope)

    # Фоновая музыка
    # FIXME: место на котором игра пролагивает (Никита пофиксит)
    pygame.mixer.music.load(os.path.join("assets/audio", "game_bg.ogg"))
    pygame.mixer.music.play(-1)
    pygame.mixer.music.set_volume(DEFAULT_MUSIC_VOLUME)

    # Игровой цикл
    while is_game_open:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                is_game_open = True
                break

        # Очистка экрана
        screen.fill((255, 255, 255))
        # Обновляем и выводим все спрайты
        player_sprites.update()
        player_sprites.draw(screen)

        clock.tick(FPS)
        pygame.display.flip()
Example #29
0
 def __init__(self, window, first=True):
     self.window = window
     self.window_width, self.window_height = window.get_size()
     self.running = True
     self.willTabQuit = True
     self.score = 0
     self.bg = pygame.image.load(str(Path('./assets/bg.jpg')))
     self.font = pygame.font.SysFont('Hack', 14, True)
     self.midFont = pygame.font.SysFont('Hack', 24, True)
     self.bigFont = pygame.font.SysFont('Hack', 80, True)
     self.player = Player(self.window)
     self.bullet = Bullet(self.window, self.player)
     self.enemy = Enemy(self.window)
     self.display = True
     self.count = 0
     self.state = 'menu' if first else 'start'
Example #30
0
    def create(self):
        self.player = Player(self.controller)
        self.hunger = Hunger(self.player)

        wall_x = 38
        wall_y = [10, 11, 12]

        walls = [
            Wall(wall_x, wall_y[0]),
            Wall(wall_x, wall_y[1]),
            Wall(wall_x, wall_y[2]),
        ]

        food_x = [43, 43, 40]
        food_y = [10, 12, 12]

        food_list = [
            Food(food_x[0], food_y[0]),
            Food(food_x[1], food_y[1]),
            Food(food_x[2], food_y[2]),
        ]

        entities = [
            self.player,
            self.hunger,
        ]

        entities.extend(food_list)
        entities.extend(walls)

        self.updater = Updater(entities)
        self.collider = Collider(entities)
        self.render = Render(entities)
Example #31
0
 def create_player(self):
     controller_type = controllers.CONTROLLER_FROM_NAME[
         self._controller_type_combobox.currentText()]
     scheme_name = self._scheme_combobox.currentText()
     scheme = self._schemes[scheme_name]
     return Player(player_id=self._player_id,
                   color_scheme=scheme,
                   controller=controller_type)
    def test_if_clear_announcements_works_correctly(self):
        player1 = Player(name='Marto')
        player1.set_hand(['10h', 'Jh', 'Qh'])
        player2 = Player(name='Rado')
        player2.set_hand(['7s', '8s', '9s'])
        team = Team(player1=player1, player2=player2)
        team.clear_announcements()

        self.assertEqual(team.player1.get_announcements(), [])
        self.assertEqual(team.player2.get_announcements(), [])
Example #33
0
    def __init__(self, dungeon, start_tile, creatures, objects):
        print creatures

        super(Level, self).__init__()
        self.objects = objects
        self.creatures = creatures
        self.dungeon = dungeon
        self.width = len(dungeon[0])
        self.height = len(dungeon)

        for y in range(self.height):
            for x in range(self.width):
                if self.dungeon[y][x]:
                    self.add(self.dungeon[y][x])

        for obj in self.objects:
            self.add(obj)
            tile = self.get(obj.x, obj.y)
            if not tile.object_on:
                tile.object_on = obj

        for creature in self.creatures:
            self.add(creature)
            tile = self.get(creature.x, creature.y)
            if not tile.creature_on:
                tile.creature_on = creature

        # Player here
        self.start_pos = dungeon[start_tile[1]][start_tile[0]].center
        self.player = Player(self.start_pos)
        self.add(self.player)
        self.creatures.append(self.player)

        self.collman = cm.CollisionManagerGrid(0, WINDOW_WIDTH, 0, WINDOW_HEIGHT, TILE_SIZE, TILE_SIZE)

        self.schedule(self.update)


        log("Loading Level object, map sise: %i:%i" % (self.width, self.height))
        log("Count of creatures: %i. Count of Objects: %i" % (len(self.creatures), len(self.objects)) )
        for x in self.get_children():
            if x.type != OBJECT_TILE:
                log(str(x))
 def setUp(self):
     self.player = Player("Socrates O. Rockefeller")
     self.enemy = Mob("Steve")
Example #35
0
class Level(cocos.layer.Layer):
    is_event_handler = True

    def __init__(self, dungeon, start_tile, creatures, objects):
        print creatures

        super(Level, self).__init__()
        self.objects = objects
        self.creatures = creatures
        self.dungeon = dungeon
        self.width = len(dungeon[0])
        self.height = len(dungeon)

        for y in range(self.height):
            for x in range(self.width):
                if self.dungeon[y][x]:
                    self.add(self.dungeon[y][x])

        for obj in self.objects:
            self.add(obj)
            tile = self.get(obj.x, obj.y)
            if not tile.object_on:
                tile.object_on = obj

        for creature in self.creatures:
            self.add(creature)
            tile = self.get(creature.x, creature.y)
            if not tile.creature_on:
                tile.creature_on = creature

        # Player here
        self.start_pos = dungeon[start_tile[1]][start_tile[0]].center
        self.player = Player(self.start_pos)
        self.add(self.player)
        self.creatures.append(self.player)

        self.collman = cm.CollisionManagerGrid(0, WINDOW_WIDTH, 0, WINDOW_HEIGHT, TILE_SIZE, TILE_SIZE)

        self.schedule(self.update)


        log("Loading Level object, map sise: %i:%i" % (self.width, self.height))
        log("Count of creatures: %i. Count of Objects: %i" % (len(self.creatures), len(self.objects)) )
        for x in self.get_children():
            if x.type != OBJECT_TILE:
                log(str(x))


    def get_path(self, a, b):
        '''
        return list of Tiles from a to b index. A*
        '''
        path = []
        return path

    def on_mouse_press(self, x, y, buttons, modifiers):
        x, y = cocos.director.director.get_virtual_coordinates(x, y)
        cam = self.parent.cam
        x = int(x + cam.x)
        y = int(y + cam.y)
        tile = self.get(x, y)
        tile.set_brightness(30)

    def on_key_press(self, k, mods):
        self.player.key_press(k)

    def get(self, x, y):
        ''' return Tile by screen x-y pos '''
        return self.dungeon[y // TILE_SIZE][x // TILE_SIZE]

    def get_index_from_pos(self, x, y):
        ''' return Tile index(x,y) from screen pos '''
        return x // TILE_SIZE, y // TILE_SIZE

    def get_by_index(self, x, y):
        ''' return Tile by index '''
        return self.dungeon[y][x]

    def get_object(self, x, y):
        ''' get the Object in x-y pos. If no object - return tile '''
        pass

    def get_objects_in_area(self, a, b):
        ''' return all objects in arena (exclude tiles) from a to b rect, by screen pos '''
        objects = set()
        return objects


    def _blocked(self, x, y):
        return (x < 0 or y < 0
                or x >= self.width or y >= self.height
                or not self.dungeon[y][x].passable)

    def _cast_light(self, cx, cy, row, start, end, radius, xx, xy, yx, yy, id):
        ''' Recursive lightcasting function '''
        if start < end:
            return
        radius_squared = radius * radius
        for j in range(row, radius + 1):
            dx, dy = -j - 1, -j
            blocked = False
            while dx <= 0:
                dx += 1
                # Translate the dx, dy coordinates into map coordinates:
                X, Y = cx + dx * xx + dy * xy, cy + dx * yx + dy * yy
                # l_slope and r_slope store the slopes of the left and right
                # extremities of the square we're considering:
                l_slope, r_slope = (dx - 0.5) / (dy + 0.5), (dx + 0.5) / (dy - 0.5)
                if start < r_slope:
                    continue
                elif end > l_slope:
                    break
                else:
                    # Our light beam is touching this square; light it:
                    if dx * dx + dy * dy < radius_squared and X >= 0 and Y >= 0 and X < self.width and Y < self.height:
                        # self.set_lit(X, Y)
                        self.tiles.append(self.dungeon[Y][X])
                    if blocked:
                        # we're scanning a row of blocked squares:
                        if self._blocked(X, Y):
                            new_start = r_slope
                            continue
                        else:
                            blocked = False
                            start = new_start
                    else:
                        if self._blocked(X, Y) and j < radius:
                            # This is a blocking square, start a child scan:
                            blocked = True
                            self._cast_light(cx, cy, j + 1, start, l_slope,
                                             radius, xx, xy, yx, yy, id + 1)
                            new_start = r_slope
            # Row is scanned; do next row unless last square was blocked:
            if blocked:
                break

    def get_fov(self, position, radius):
        ''' fov - field of view, get all viewed tiles from position '''
        # Multipliers for transforming coordinates to other octants:
        mult = [[1, 0, 0, -1, -1, 0, 0, 1],
                [0, 1, -1, 0, 0, -1, 1, 0],
                [0, 1, 1, 0, 0, -1, -1, 0],
                [1, 0, 0, 1, -1, 0, 0, -1]]
        self.tiles = []
        for oct in range(8):
            self._cast_light(position[0], position[1], 1, 1.0, 0.0, radius, mult[0][oct],
                             mult[1][oct], mult[2][oct], mult[3][oct], 0)

        self.tiles.append(self.dungeon[position[1]][position[0]])
        for tile in self.get_children():
            if (tile.type == OBJECT_TILE):
                tile.set_brightness(40)

        for tile in self.tiles:
            tile.set_brightness(100)
            tile.explored = True

        return self.tiles

    def update(self, dt=1):
        self._update_visible()
        self._update_z()

    # TODO: Перебирает все элементы. Можно упростить?
    def _update_visible(self):
        for ch in self.get_children():
            ch.visible = False
            if (ch.type == OBJECT_TILE and not ch.explored):
                continue
            if self.parent.cam.is_object_in(ch):
                ch.visible = True

    def _update_z(self):
        ''' Sort all children objects by Y coord to correct render
            TODO: grab objects placed in camera zone only '''
        is_changed = False
        for i in range(len(self.children)):
            ch = self.children[i]
            if ch[1].visible:
                # ty - pos y in render_list (from up to down)
                ty = ch[0]
                # ch[1].y - cur y in real obj (from down to up). That's why WHeight - ch[1].y
                ty_obj = WINDOW_HEIGHT - ch[1].y
                # if now checking tile: get -2y , for low render prioriry
                if ch[1].type == OBJECT_TILE:
                    ty_obj -= 2
                if ty != ty_obj:
                    tmp = list(ch)
                    tmp[0] = ty_obj
                    self.children[i] = tuple(tmp)
                    is_changed = True

        if is_changed:
            self.children.sort()