예제 #1
0
    def __init__(self, filename, renderer):
        # Load TMX data
        self.tmx_data = load_pysdl2(filename=filename, renderer=renderer)

        # Make data source for the map
        self.map_data = pyscroll.TiledMapData(self.tmx_data)

        # Make the scrolling layer
        screen_size = (400, 400)
        map_layer = pyscroll.BufferedRenderer(self.map_data, screen_size)

        # make the pygame SpriteGroup with a scrolling map
        group = pyscroll.PyscrollGroup(map_layer=map_layer)

        # Add sprites to the group
        group.add(sprite)

        # Center the layer and sprites on a sprite
        group.center(sprite.rect.center)

        # Draw the layer
        # If the map covers the entire screen, do not clear the screen:
        # Clearing the screen is not needed since the map will clear it when drawn
        # This map covers the screen, so no clearing!
        group.draw(screen)

        # adjust the zoom (out)
        map_layer.zoom = .5

        # adjust the zoom (in)
        map_layer.zoom = 2.0
예제 #2
0
    def setup(self):
        pygame.init()
        init_spritesheet()
        from src.spritesheet import RougeSheet
        self.screen_size = (960, 600)

        self.screen = pygame.display.set_mode(self.screen_size)
        pygame.display.set_caption("Scroller Game")

        self.clock = pygame.time.Clock()

        self.map_data = load_map("map4")
        self.map = pyscroll.TiledMapData(self.map_data)
        self.map_layer = pyscroll.BufferedRenderer(self.map, self.screen_size)
        self.map_layer.zoom = 3

        self.walls = create_walls(self.map_data)
        self.player = basic_player(self, RougeSheet)
        self.enemies = pygame.sprite.Group()
        add_mobs(self, self.map_data)

        self.all_sprites = pyscroll.PyscrollGroup(map_layer=self.map_layer)
        self.all_sprites.add(self.player)
        self.all_sprites.add(self.enemies)
        self.all_sprites.center(self.player.rect.center)
예제 #3
0
 def __init__(self, game, filename):
     self.game = game
     self.tmx_data = load_pygame('assets/maps/' + filename)
     self.map_data = pyscroll.TiledMapData(self.tmx_data)
     self.size = [
         self.map_data.map_size[0] * self.map_data.tile_size[0],
         self.map_data.map_size[1] * self.map_data.tile_size[1]
     ]
     self.map_layer = pyscroll.BufferedRenderer(self.map_data, self.size)
     self.group = pyscroll.PyscrollGroup(map_layer=self.map_layer)
예제 #4
0
    def __init__(self):
        self.score = 0
        self.start_screen = True
        self.start_screen_obj = StartScreen()
        self.game_over = False
        self.pause = False
        self.game_over_music_enabled = False
        self.fps = 0.0
        self.font = pygame.font.Font(os.path.join('fonts', 'PressStart2P.ttf'),
                                     8)

        self.all_sprites_list = pygame.sprite.Group()
        self.player_object_list = pygame.sprite.Group()
        #it contains all enemy sprites including bullets
        self.enemy_object_list = pygame.sprite.Group()
        #it contains only ships and monsters
        self.enemy_list = pygame.sprite.Group()

        Player.containers = self.all_sprites_list, self.player_object_list
        EnemySmallSpaceship.containers = self.all_sprites_list, self.enemy_object_list, self.enemy_list
        Whale.containers = self.all_sprites_list, self.enemy_object_list, self.enemy_list
        Bullet.containers = self.all_sprites_list, self.enemy_object_list
        BulletPlayer.containers = self.all_sprites_list, self.player_object_list

        self.last_time_enemy_killed = pygame.time.get_ticks()
        self.milliseconds_per_kill = 1500

        # Create the player
        self.player = Player()

        self.interval_spawn_enemy = 1500
        self.last_time_spawn_enemy = pygame.time.get_ticks()

        self.max_score = 0

        # Test boss
        #add_whale()

        self.start_screen_obj.play_music()

        # Load TMX data
        tmx_data = load_pygame(os.path.join('maps', 'mapcorridor.tmx'))

        # Make data source for the map
        map_data = pyscroll.TiledMapData(tmx_data)

        # Make layer
        self.map_layer = pyscroll.BufferedRenderer(
            map_data, (SCREEN_WIDTH, SCREEN_HEIGHT))
        self.center_map = [
            self.map_layer.map_rect.width // 2,
            self.map_layer.map_rect.height - SCREEN_HEIGHT // 2
        ]
예제 #5
0
파일: maps.py 프로젝트: BJL/gamedev4kid
    def loadTiledMap(self,
                     screen_w=800,
                     screen_h=600,
                     path='maps/testmap2.tmx'):
        self.tiled_map = load_pygame(path)
        self.map_data = pyscroll.TiledMapData(self.tiled_map)
        (w, h) = self.map_data.map_size
        self.rect = Rect(0, 0, w * 64, h * 64)
        self.map_layer = pyscroll.BufferedRenderer(self.map_data,
                                                   (screen_w, screen_h),
                                                   clamp_camera=True)

        return self.map_layer
예제 #6
0
 def init_graphics(self):
     pygame.display.set_caption('Dinos äventyr')
     self.screen = pygame.display.set_mode(self.size, pygame.RESIZABLE)
     self.background = pygame.Surface(self.screen.get_size())
     self.tmx_data = pytmx.load_pygame("real_map.tmx")
     # Make data source for the map
     self.map_data = pyscroll.TiledMapData(self.tmx_data)
     # Make the scrolling layer
     screen_size = (self.width, self.height)
     self.map_layer = pyscroll.BufferedRenderer(self.map_data, screen_size, clamp_camera=True, tall_sprites=1)
     self.map_layer.zoom = 2
     # make the PyGame SpriteGroup with a scrolling map
     self.group = pyscroll.PyscrollGroup(map_layer=self.map_layer)
예제 #7
0
    def loadMap(self, fname):
        self.tmx_data = load_pygame(fname)

        # Make data source for the map
        self.map_data = pyscroll.TiledMapData(self.tmx_data)

        # Make the scrolling layer
        self.map_layer = pyscroll.BufferedRenderer(self.map_data,
                                                   Config.screen_size,
                                                   alpha=False,
                                                   clamp_camera=True)

        # here, we know the space of our world, so store it in the class
        h = self.tmx_data.height * self.tmx_data.tileheight
        w = self.tmx_data.width * self.tmx_data.tilewidth
        Config.world_size = (w, h)
예제 #8
0
    def switch_map(self, map_name='monestary', spawn=True):
        """
        Switches to input map
        """
        self.current_map = map_name
        # Pyscroll
        tm = pytmx.load_pygame(path.join(self.maps_folder,
                                         '{}.tmx'.format(map_name)),
                               pixelalpha=True)
        self.map_data = pyscroll.TiledMapData(tm)
        screen_size = (WIDTH, HEIGHT)
        self.map_layer = pyscroll.BufferedRenderer(self.map_data, screen_size)
        # Instantiate all_sprites group
        self.all_sprites = pyscroll.PyscrollGroup(map_layer=self.map_layer)

        for tile_object in tm.objects:
            obj_center = vector(tile_object.x + tile_object.width / 2,
                                tile_object.y + tile_object.height / 2)
            if tile_object.name == 'player':
                if spawn:
                    self.player = Player(self, obj_center.x, obj_center.y)
            elif not spawn:
                self.all_sprites.add(self.player)
            if tile_object.name == 'mob':
                Mob(self, obj_center.x, obj_center.y, tile_object.type)
            if tile_object.name == 'npc':
                Npc(self, obj_center.x, obj_center.y, tile_object.type)
            if tile_object.name == 'wall':
                Obstacle(self, tile_object.x, tile_object.y, tile_object.width,
                         tile_object.height)
            if tile_object.name == 'portal':
                Portal(self, obj_center.x, obj_center.y, tile_object.width,
                       tile_object.height, tile_object.type)
            if tile_object.name == 'spawn':
                Spawn(self, obj_center.x, obj_center.y, tile_object.width,
                      tile_object.height, tile_object.type)
            if tile_object.name == 'readable':
                Readable(self, obj_center.x, obj_center.y, tile_object.width,
                         tile_object.height, tile_object.type)
            if tile_object.name in POTION_ITEMS:
                Potion(self, obj_center, tile_object.name)
            if tile_object.name in SPELL_ITEMS:
                Spell(self, obj_center, tile_object.name)
        self.paused = False
        self.night = False
        self.inventory = False
        self.effect_sounds['level_start'].play()
예제 #9
0
    def __init__(self, fname):

        self.width, self.height = 1024, 768
        self.tile_width, self.tile_height = 64, 32

        self.fullname = os.path.join('data', '%s.tmx' % fname)

        self.tmx_data = load_pygame(self.fullname)

        self.map_data = pyscroll.TiledMapData(self.tmx_data)

        self.tileset = load_image("iso-64x64-outside.png")

        self.map_layer = pyscroll.IsometricBufferedRenderer(self.map_data, (self.width, self.height))
        self.map_layer.zoom = 2

        self.group = PyscrollGroup(map_layer=self.map_layer, default_layer=2)
예제 #10
0
    def loadMap(self):
        self.wmap.tmx = load_pygame(self.wmap.fname)

        # here, we know the space of our world, so store it in the class
        # used after that to init the Physics engine.
        w = self.wmap.tmx.width * self.wmap.tmx.tilewidth
        h = self.wmap.tmx.height * self.wmap.tmx.tileheight
        bounce.update_world_size((w, h))

        # Make data source for the map
        self.wmap.data = pyscroll.TiledMapData(self.wmap.tmx)

        # Make the scrolling layer
        # with screen_rect_size, creates a buffer for the screen,
        # but we need a full world buffer (to allow blitting the physics layer when needed)
        #self.wmap.layer = pyscroll.BufferedRenderer(self.wmap.data, bounce.Screen.rect.size, alpha=False, clamp_camera=True)
        self.wmap.layer = pyscroll.BufferedRenderer(
            self.wmap.data,
            bounce.Physics.pixel_rect.size,
            alpha=False,
            clamp_camera=True)
예제 #11
0
    def load_map(self, map_name, spawn_point):
        self.tmx_data = load_pygame(BASEDIR / "assets" / "maps" /
                                    f"{map_name}.tmx")
        self.map_data = pyscroll.TiledMapData(self.tmx_data)
        self.map_layer = pyscroll.BufferedRenderer(self.map_data,
                                                   self.GAME_AREA_SIZE_PIXELS)
        self.map_sprite_group = pyscroll.PyscrollGroup(
            map_layer=self.map_layer, default_layer=3)

        # Find first spawn point
        spawns_layer = self.tmx_data.get_layer_by_name("spawns")
        self.spawns = {
            spawn.name: [spawn.x, spawn.y]
            for spawn in spawns_layer
        }
        self.hero.position = self.spawns[spawn_point]
        self.map_sprite_group.add(self.hero)

        # Build impassable rect list
        impassables_layer = self.tmx_data.get_layer_by_name("impassables")
        self.impassables = [object_to_rect(o) for o in impassables_layer]

        doors_layer = self.tmx_data.get_layer_by_name("doors")
        self.doors = [(object_to_rect(o), o) for o in doors_layer]
예제 #12
0
    def do_handshake(self):
        hs_step = self.client.block_until_get_step(net.HANDSHAKE_STEP)
        for command in hs_step.commands:
            if type(command) == commands.Handshake:
                # Create players with entity IDs corresponding to their player IDs
                for player_id in sorted(command.startlocs):
                    self.entities.add_ent(
                        Entity({
                            'player_id': int(player_id),
                            'faction': command.startlocs[player_id]['fac']
                        }))
                # Now that we have player ents with the right IDs, spawn other stuff
                for player_id in sorted(command.startlocs):
                    info = command.startlocs[player_id]
                    start_building = self.data.data['factions'][
                        info['fac']]['start_building']
                    self.entities.add_ent(
                        self.data.spawn(utype=start_building,
                                        pos=info['start'],
                                        owner=int(player_id)))

            self.player_id = command.your_id

            self.map = load_pygame(command.map)

            self.map_layer = pyscroll.BufferedRenderer(
                pyscroll.TiledMapData(self.map), self.screen_size)

        print("Handshake complete. Your player ID: {}".format(self.player_id))

        self.state_hash = net.EMPTY_HASH

        # TODO: When implementing factions/game modes, use this area to
        # instantiate the GUI differently based on the handshake.
        # For now we hard code how the GUI will look.
        self.gui = gui.GUI(
            self.entities, self.data.sprites['scand_mouse'], self.screen,
            self.data.data, self.player_id, self,
            ((self.map.width * self.map.tilewidth) - self.screen_size[0],
             (self.map.height * self.map.tileheight) -
             self.screen_size[1]))  # TODO: Clean up this leaky abstraction

        self.entities.add_draw_system(
            gui.SelectionDrawSystem(
                screen=self.screen,
                gui=self.gui,
                sprite=self.data.sprites['scand_selection']),
            0)  # We want it at 0 so as to be below the sprites.

        self.entities.add_draw_system(
            gui.GoalDrawSystem(gui=self.gui,
                               sprite=self.data.sprites['scand_mouse']))

        self.entities.add_draw_system(
            gui.PathDrawSystem(
                gui=self.gui,
                sprite=self.data.sprites['scand_mouse'],
                tile_width=self.map.tilewidth,
                tile_height=self.map.tileheight,
            ))

        self.entities.add_filter(gui.SpriteClickedFilter(self.data.sprites))
        # Pathing data - loading & displaying

        self.pathmap = movement.Pathmap(self.map)

        if 'show_pathing' in self.settings:
            self.entities.add_draw_system(
                movement.PathabilityDrawSystem(
                    pathmap=self.pathmap,
                    tile_height=self.map.tileheight,
                    tile_width=self.map.tilewidth,
                    sprite=self.data.sprites['path'],
                    screen=self.screen))
        self.entities.get_system("PathFollowSystem").setup_post_handshake(
            self.pathmap, )
예제 #13
0
    def initialize(self, context):

        screen = pygame.display.get_surface()
        adventure_graph = build_graph_from_yaml_data(
            load_yaml_data(get_data_asset(self.graph_yaml)))
        self.visitor = Visitor.visit_graph(adventure_graph, context)

        tmx_data = load_pygame(resources.get_map_asset(self.graph_tmx))
        map_data = pyscroll.TiledMapData(tmx_data)
        map_layer_size = screen.get_width(), int(screen.get_height() * .80)
        map_layer_rect = Rect((0, 0), map_layer_size)
        map_layer = pyscroll.BufferedRenderer(map_data, map_layer_size)

        self.scroll_group = PyscrollGroup(map_layer=map_layer)

        self.pointer = PointerSprite(self.vertex_group, self.scroll_group)
        # self.pointer.selected_vertex_id = "START"
        self.sprites.add(self.pointer, layer=100)

        sw, sh = screen.get_size()
        hud_rect = Rect(20, sh * .76, sw * .80, sh * .2)
        border_image = load_image('border-default.png').convert_alpha()
        self.hud_group = HUDGroup(hud_rect, border_image)
        info = VertexInfoSprite(self.visitor)
        info.rect = Rect(12, 12, hud_rect.width - 250, hud_rect.height - 24)
        self.hud_group.add(info)
        self.hud_group.open()

        self.hud_button = HUDButton(self.hud_group, 850, 70)
        self.hud_group.add(self.hud_button)

        edges = list()
        for vertex in self.visitor.graph.vertex_index.values():
            vertex_sprite = VertexSprite(vertex)
            self.vertex_group.add(vertex_sprite)
            self.scroll_group.add(vertex_sprite)
            for edge in vertex.edges:
                edges.append(edge)

        edge_sprites = dict()
        for edge in edges:
            key = [edge.from_vertex.vertex_id, edge.to_vertex.vertex_id]
            key.sort()
            key = tuple(key)
            if key not in edge_sprites:
                edge_sprite = EdgeSprite(edge, self.scroll_group)
                from_vertex_sprite = self.vertex_group[
                    edge.from_vertex.vertex_id]
                to_vertex_sprite = self.vertex_group[edge.to_vertex.vertex_id]
                from_vertex_sprite.edge_sprites.append(edge_sprite)
                to_vertex_sprite.edge_sprites.append(edge_sprite)
                edge_sprites[key] = edge_sprite

        self.visitor_cursor = VisitorCursor(self.visitor, self.pointer,
                                            self.vertex_group,
                                            self.scroll_group)

        if context.get('show_clippie', False):
            c = Clippie(self.sprites, self._animations, context)
            c.rect.topleft = 1100, 550
            self.sprites.add(c)
            self.visitor_cursor.clippie = c

        clock = pygame.time.Clock()

        pygame.display.flip()
        pygame.mouse.set_visible(False)

        while True:
            delta = clock.tick(60)
            events = pygame.event.get()
            self.hud_group.update(delta, events)
            for event in events:
                if event.type == pygame.QUIT:
                    sys.exit(0)
                elif event.type == pygame.KEYDOWN or self.hud_button.handle_click:
                    vertex_id = self.visitor_cursor.current_vertex_sprite.vertex_id
                    if self.hud_button.handle_click or pygame.K_SPACE == event.key and vertex_id == self.pointer.selected_vertex_id:
                        self.hud_button.handle_click = False
                        if self.visitor.current_vertex.can_activate(
                                self.visitor.context):
                            activation_dict = self.visitor.activate_current_vertex(
                            )
                            if activation_dict[
                                    "command"] == "launch-mini-game":
                                r = RunMinigameActivation(
                                    activation_dict["command"],
                                    activation_dict["activation-keyword-args"])

                                logger.debug(
                                    "Stating game: {} with arguments {}".
                                    format(r.mini_game_name,
                                           r.mini_game_keyword_args))
                                unhandled_actions = self.minigame_manager.run_minigame(
                                    r.mini_game_name, self.visitor.context,
                                    r.post_run_actions,
                                    **r.mini_game_keyword_args
                                    if r.mini_game_keyword_args is not None
                                    else {})

                                if self.has_exit_action(unhandled_actions):
                                    return

                        else:
                            vertex = self.visitor.current_vertex
                            failing = vertex.activation_pre_requisites.get_failing_pre_requisites(
                                self.visitor.context)
                            self.visitor.context[
                                'gamestate.dialog_text'] = failing[0].hint
                            self.visitor_cursor.animations.add(
                                Task(self.visitor_cursor.clear_hint, 5000))

            self.scroll_group.update(delta, events)
            # self.hud_group.update(delta, events)
            self.sprites.update(delta, events)
            self._animations.update(delta)
            self._update_edge_colors()

            x_offset = (
                (self.visitor_cursor.rect.x - self.scroll_group.view.x) -
                self.pointer.rect.x) / 2
            self.scroll_group.center(
                (self.visitor_cursor.rect.x - x_offset, 0))

            self.scroll_group.draw(screen, map_layer_rect)

            screen.fill((200, 200, 200), (0, sh * .75, 1280, 200))

            self.hud_group.draw(screen)
            self.sprites.draw(screen)

            screen.blit(self.pointer.image, self.pointer.rect)
            pygame.display.flip()
예제 #14
0
파일: game.py 프로젝트: bitcraft/sanic
    def __init__(self):
        self.time = 0
        self.death_reset = 0
        self.running = False
        self.models = set()
        self.sanic = None
        self.bg = None
        self.models_lock = threading.Lock()
        self.hud_group = pygame.sprite.Group()
        self._add_queue = set()
        self._remove_queue = set()
        self.timestep = config.getfloat('world', 'timestep')
        self.draw_background = config.getboolean('display', 'draw-background')
        if self.draw_background:
            self.bg = resources.images['default-bg']

        self.keyboard_input = playerinput.KeyboardPlayerInput()

        self.tmx_data = resources.maps['level0']
        self.map_data = pyscroll.TiledMapData(self.tmx_data)
        self.map_height = self.map_data.height * self.map_data.tileheight

        # manually set all objects in the traps layer to trap collision type
        for layer in self.tmx_data.objectgroups:
            if layer.name == 'Traps':
                for index, obj in enumerate(layer):
                    obj.name = 'trap_{}'.format(index)
            elif layer.name == 'Boundaries':
                for index, obj in enumerate(layer):
                    obj.name = 'boundary_{}'.format(index)
            elif layer.name == 'Physics':
                for index, obj in enumerate(layer):
                    pass
            elif layer.name == 'Stairs':
                for index, obj in enumerate(layer):
                    obj.name = 'stairs_{}'.format(index)

        # set up the physics simulation
        self.space = pymunk.Space()
        self.space.gravity = (0, config.getfloat('world', 'gravity'))
        shapes = load_shapes(self.tmx_data, self.space, resources.level_xml)

        # load the vp group and the single vp for level drawing
        self.vpgroup = sprite.ViewPortGroup(self.space, self.map_data)
        self.vp = sprite.ViewPort()
        self.vpgroup.add(self.vp)

        # set collision types for custom objects
        # and add platforms
        for name, shape in shapes.items():
            logger.info("loaded shape: %s", name)
            if name.startswith('trap'):
                shape.collision_type = collisions.trap
            elif name.startswith('boundary'):
                shape.collision_type = collisions.boundary
            elif name.startswith('moving'):
                self.handle_moving_platform(shape)
            elif name.startswith('stairs'):
                self.handle_stairs(shape)

        self.new_sanic()
예제 #15
0
        print(obj.name)
        if not hasattr(obj, "points"):
            #obj.height
            #obj.width
            #obj.x
            #obj.y
            obj.__dict__["points"] = [(obj.x, obj.y),
                                      (obj.x, obj.y + obj.height),
                                      (obj.x + obj.width, obj.y + obj.height),
                                      (obj.x + obj.width, 0)]

        for p in obj.points:
            print(p)

    # Make data source for the map
    map_data = pyscroll.TiledMapData(tmx_data)

    # Make the scrolling layer
    for p in tmx_data.properties.keys():
        print("%s: %s", p, tmx_data.properties[p])

    map_layer = pyscroll.BufferedRenderer(map_data, screen_size, alpha=False)

    # make the pygame SpriteGroup with a scrolling map
    group = pyscroll.PyscrollGroup(map_layer=map_layer)

    px, py = (map_layer.map_rect.width / 2, map_layer.map_rect.height / 2)
    group.center((px, py))
    # Add sprites to the group
    #group.add(sprite)
예제 #16
0
theMix = pygame.mixer.Channel(1)
songNumber = 1
theSong = pygame.mixer.Sound("WhoToJoin.ogg")
theMix.play(theSong,loops=-1,fade_ms=1500)
screenSize = [800,600]
screen = pygame.display.set_mode(screenSize)
 

pygame.display.set_caption("War of the Trinity")
 
clock = pygame.time.Clock()



tmxData = load_pygame("theMap.tmx")
mapData = pyscroll.TiledMapData(tmxData)
mapSprite = pyscroll.BufferedRenderer(mapData,screenSize)

group = pyscroll.PyscrollGroup(map_layer=mapSprite)
player = Player()
spriteList = pygame.sprite.Group()
creatureList = pygame.sprite.Group()
specialList = pygame.sprite.Group()
testCreatureList = [Creature(64,64)]
for i in range(0,99):
    x = random.randint(1,99)*32
    y = random.randint(1,99)*32
    testCreature = Creature(x,y)
    testCreatureList.append(testCreature)
scienceMan = ScienceMan(640,96,theSong)
mutantMan = MutantMan(1280,160,theSong)
예제 #17
0
 def __init__(self, map_filepath):
     self.tmx_data = GameUtil.load_map(map_filepath)
     self.map_data = pyscroll.TiledMapData(self.tmx_data)
     self.surfacedata = {}
     self.camera = GameLevelCamera(self)
예제 #18
0
    def __init__(self, data):
        tmx_data = MapTitle[data.map_name].value[1]
        map_data = pyscroll.TiledMapData(tmx_data)
        self.map_layer = pyscroll.BufferedRenderer(map_data,
                                                   (WINDOWWIDTH, WINDOWHEIGHT))
        self.map_layer.zoom = 2
        self.view = pyscroll.PyscrollGroup(map_layer=self.map_layer,
                                           default_layer=PLAYERLAYER)

        tilewidth = tmx_data.tilewidth
        tileheight = tmx_data.tileheight
        self.width = int(tmx_data.width * tilewidth)
        self.height = int(tmx_data.height * tileheight)
        self.window_width = WINDOWWIDTH
        self.window_height = WINDOWHEIGHT

        self.title = MapTitle[data.map_name].value[0]

        self.high_blocker_rects = []
        self.low_blocker_rects = []
        self.quest_blocker_rects = []
        self.sounds = []
        self.start_pos = []
        self.portals = []
        self.heroes = []
        self.shops = []
        self.schools = []
        self.trainers = []
        self.inns = []
        self.people = []
        self.notes = []
        self.signs = []
        self.locations = []
        self.text_events = []
        self.move_events = []
        self.chests = []
        self.sparkly = []

        rnd = random.randint(1, 6)

        for rect in tmx_data.get_layer_by_name(HIGHBLOCKER):
            self.high_blocker_rects.append(self._pg_rect(rect))
        for rect in tmx_data.get_layer_by_name(LOWBLOCKER):
            self.low_blocker_rects.append(self._pg_rect(rect))
        for nrect in tmx_data.get_layer_by_name(SOUNDS):
            self.sounds.append(NamedRect(nrect.name, self._pg_rect(nrect)))
        for obj in tmx_data.get_layer_by_name(STARTPOS):
            self.start_pos.append(
                Portal(obj.name, self._pg_rect(obj), data.map_name, obj.type,
                       self._has_dir(obj, 'direction')))
        for obj in tmx_data.get_layer_by_name(PORTALS):
            self.portals.append(
                Portal(data.map_name, self._pg_rect(obj), obj.name, obj.type))
        for obj in tmx_data.get_layer_by_name(EVENTS):
            if obj.name.startswith('location'):
                self.locations.append(NamedRect(obj.name, self._pg_rect(obj)))
            elif obj.name.startswith('text'):
                # in obj.type kan iets staan, als daar bijv zwart staat, dan heeft het text_event een zwarte achtergrond
                self.text_events.append(
                    NamedRect(obj.name, self._pg_rect(obj), obj.type))
            elif obj.name.startswith('move'):
                self.move_events.append(NamedRect(obj.name,
                                                  self._pg_rect(obj)))

        for obj in tmx_data.get_layer_by_name(OBJECTS):
            if obj.name == 'blocker':
                # in obj.type staat de bijbehorende quest key.
                self.quest_blocker_rects.append(
                    NamedRect(obj.type, self._pg_rect(obj)))
            elif obj.name.startswith('shop'):
                shop_object = Person(obj.name,
                                     ShopDatabase[obj.name].value['sprite'],
                                     self._pg_rect(obj), OBJECTLAYER,
                                     self._has_dir(obj, 'direction'), obj.type)
                # als er in obj.type iets staat, dan is het een lege sprite en dus geen blocker.
                if not obj.type:
                    self.high_blocker_rects.append(shop_object.get_blocker())
                self.shops.append(shop_object)
            elif obj.name.startswith('school'):
                school_object = Person(
                    obj.name, SchoolDatabase[obj.name].value['sprite'],
                    self._pg_rect(obj), OBJECTLAYER,
                    self._has_dir(obj, 'direction'), obj.type)
                if not obj.type:
                    self.high_blocker_rects.append(school_object.get_blocker())
                self.schools.append(school_object)
            elif obj.name.startswith('trainer'):
                trainer_object = Person(
                    obj.name, TrainerDatabase[obj.name].value['sprite'],
                    self._pg_rect(obj), OBJECTLAYER,
                    self._has_dir(obj, 'direction'), obj.type)
                if not obj.type:
                    self.high_blocker_rects.append(
                        trainer_object.get_blocker())
                self.trainers.append(trainer_object)
            elif obj.name.startswith('inn'):
                inn_object = Person(obj.name,
                                    InnDatabase[obj.name].value['sprite'],
                                    self._pg_rect(obj), OBJECTLAYER,
                                    self._has_dir(obj, 'direction'), obj.type)
                if not obj.type:
                    self.high_blocker_rects.append(inn_object.get_blocker())
                self.inns.append(inn_object)
            elif obj.name == 'person107':
                if int(obj.type) == rnd:
                    person_object = Walking2(
                        obj.name, PeopleDatabase[obj.name].value['sprite'],
                        self._pg_rect(obj), OBJECTLAYER,
                        self._has_dir(obj, 'direction'))
                    self.people.append(person_object)
                else:
                    pass
            elif obj.name == 'person124':
                person_object = Person(
                    obj.name, PeopleDatabase[obj.name].value['sprite'],
                    self._pg_rect(obj), OBJECTLAYER,
                    self._has_dir(obj, 'direction'), True)
                self.people.append(person_object)
            elif obj.name.startswith('person'):
                # als er in obj.type iets staat, dan is het een walking person
                if obj.type:
                    person_object = Walking(
                        obj.name, PeopleDatabase[obj.name].value['sprite'],
                        self._pg_rect(obj), OBJECTLAYER,
                        self._has_dir(obj, 'direction'))
                else:
                    person_object = Person(
                        obj.name, PeopleDatabase[obj.name].value['sprite'],
                        self._pg_rect(obj), OBJECTLAYER,
                        self._has_dir(obj, 'direction'), None)
                # als er een tijdspanne aan de personage zit
                if PeopleDatabase[obj.name].value.get('time1'):
                    time1 = PeopleDatabase[obj.name].value['time1']
                    time2 = PeopleDatabase[obj.name].value['time2']
                    timestamp = datetime.datetime.now()
                    # print(timestamp)
                    if time1 < timestamp < time2:

                        if PeopleDatabase[obj.name].value.get('chapter'):
                            # zoek de .name op van de chapter in de peopledatabase. (als die er is)
                            chapter_name = PeopleDatabase[
                                obj.name].value['chapter'].name
                            # die bevat een dict met 1 waarde
                            chapter_dict = data.chapters[chapter_name]
                            # dat is een boolean
                            chapter_bool = chapter_dict['condition']
                            if chapter_bool:
                                self.people.append(person_object)
                                if not obj.type:
                                    self.high_blocker_rects.append(
                                        person_object.get_blocker())
                        else:
                            self.people.append(person_object)
                            if not obj.type:
                                self.high_blocker_rects.append(
                                    person_object.get_blocker())
                else:
                    self.people.append(person_object)
                    # geen blocker voor walking people, die worden actueel in window geladen bij check_blocker.
                    if not obj.type:
                        self.high_blocker_rects.append(
                            person_object.get_blocker())

            elif obj.name.startswith('note'):
                self.notes.append(NamedRect(obj.name, self._pg_rect(obj)))
            elif obj.name.startswith('sign'):
                sign_object = Sign(obj.name, self._pg_rect(obj), OBJECTLAYER,
                                   obj.type)
                self.high_blocker_rects.append(sign_object.get_blocker())
                self.signs.append(sign_object)
            elif obj.name.startswith('chest'):
                if 'time1' in TreasureChestDatabase[obj.name].value:
                    time1 = TreasureChestDatabase[obj.name].value['time1']
                    time2 = TreasureChestDatabase[obj.name].value['time2']
                    timestamp = datetime.datetime.now()
                    if time1 < timestamp < time2:
                        chest_object = TreasureChest(obj.name,
                                                     self._pg_rect(obj),
                                                     OBJECTLAYER)
                        self.low_blocker_rects.append(
                            chest_object.get_blocker())
                        self.chests.append(chest_object)
                else:
                    chest_object = TreasureChest(obj.name, self._pg_rect(obj),
                                                 OBJECTLAYER)
                    self.low_blocker_rects.append(chest_object.get_blocker())
                    self.chests.append(chest_object)
            elif obj.name.startswith('sparkly'):
                # als er in obj.type iets staat, dan is het een lege sprite.
                sparkly_object = Sparkly(obj.name, self._pg_rect(obj),
                                         OBJECTLAYER, obj.type)
                self.sparkly.append(sparkly_object)
            elif obj.name == 'hero':
                if obj.type == 'zwammix':
                    timestamp = datetime.datetime.now()
                    if timestamp < datetime.datetime(2017, 5, 22, 16, 00):
                        break

                hero_object = Person(obj.type,
                                     HeroDatabase[obj.type].value['spr'],
                                     self._pg_rect(obj), OBJECTLAYER,
                                     self._has_dir(obj, 'direction'), None)
                # geen high_blocker zoals bij bijv shops, omdat hero's er soms niet op de map kunnen staan,
                # het laden van high_blockers gebeurt in window.
                self.heroes.append(hero_object)
            else:
                Console.error_unknown_map_object()
                raise NameError