def main():
    global keyboard, walls, scroller
    from cocos.director import director
    director.init(width=800, height=600, autoscale=False)

    print(description)

    # add the tilemap and the player sprite layer to a scrolling manager
    scroller = layer.ScrollingManager()
    walls = tiles.load('tmx_collision.tmx')['walls']
    assert isinstance(walls, tiles.TmxObjectLayer)
    scroller.add(walls, z=0)

    # make the function to handle collision between actors and walls
    mapcollider = TmxObjectMapCollider()
    mapcollider.on_bump_handler = mapcollider.on_bump_bounce
    fn_collision_handler = mapcolliders.make_collision_handler(
        mapcollider, walls)

    # make the function to set visual focus at position
    fn_set_focus = scroller.set_focus

    # create a layer to put the player in
    actors_layer = layer.ScrollableLayer()
    ball = Ball((300, 300), (600, 600), fn_collision_handler, fn_set_focus,
                (255, 0, 255))
    actors_layer.add(ball)

    scroller.add(actors_layer, z=1)

    # set the player start using the object with the 'player_start' property
    player_start = walls.find_cells(player_start=True)[0]
    ball.position = player_start.center

    # set focus so the player is in view
    scroller.set_focus(*ball.position)

    # extract the player_start, which is not a wall
    walls.objects.remove(player_start)

    # construct the scene with a background layer color and the scrolling layers
    platformer_scene = cocos.scene.Scene()
    platformer_scene.add(layer.ColorLayer(100, 120, 150, 255), z=0)
    platformer_scene.add(scroller, z=1)

    # track keyboard presses
    keyboard = key.KeyStateHandler()
    director.window.push_handlers(keyboard)

    # run the scene
    director.run(platformer_scene)
def main():
    global keyboard, walls, scroller
    from cocos.director import director
    director.init(width=800, height=600, autoscale=False)

    print(description)

    # add the tilemap and the player sprite layer to a scrolling manager
    scroller = layer.ScrollingManager()
    walls = tiles.load('tmx_collision.tmx')['walls']
    assert isinstance(walls, tiles.TmxObjectLayer)
    scroller.add(walls, z=0)

    # make the function to handle collision between actors and walls
    mapcollider = TmxObjectMapCollider()
    mapcollider.on_bump_handler = mapcollider.on_bump_bounce
    fn_collision_handler = mapcolliders.make_collision_handler(mapcollider, walls)

    # make the function to set visual focus at position
    fn_set_focus = scroller.set_focus
    
    # create a layer to put the player in
    actors_layer = layer.ScrollableLayer()
    ball = Ball((300, 300), (600, 600), fn_collision_handler, fn_set_focus, (255, 0, 255)) 
    actors_layer.add(ball)

    scroller.add(actors_layer, z=1)

    # set the player start using the object with the 'player_start' property
    player_start = walls.find_cells(player_start=True)[0]
    ball.position = player_start.center

    # set focus so the player is in view
    scroller.set_focus(*ball.position)

    # extract the player_start, which is not a wall
    walls.objects.remove(player_start)

    # construct the scene with a background layer color and the scrolling layers
    platformer_scene = cocos.scene.Scene()
    platformer_scene.add(layer.ColorLayer(100, 120, 150, 255), z=0)
    platformer_scene.add(scroller, z=1)

    # track keyboard presses
    keyboard = key.KeyStateHandler()
    director.window.push_handlers(keyboard)

    # run the scene
    director.run(platformer_scene)
def main():
    global walls, scroller, platformer_scene
    from cocos.director import director
    director.init(width=800, height=600, autoscale=False)

    print(description)

    # add the tilemap and the player sprite layer to a scrolling manager
    scroller = layer.ScrollingManager()
    walls = tiles.load('tmx_collision.tmx')['walls']
    assert isinstance(walls, tiles.TmxObjectLayer)
    scroller.add(walls, z=0)

    # make the function to handle collision between actors and walls
    mapcollider = TmxObjectMapCollider()
    mapcollider.on_bump_handler = mapcollider.on_bump_bounce
    fn_collision_handler = mapcolliders.make_collision_handler(mapcollider, walls)

    # make the function to set visual focus at position
    fn_set_focus = scroller.set_focus
    
    scroller.add(Actors(fn_collision_handler), z=1)

    # set the player start using the object with the 'player_start' property
    player_start = walls.find_cells(player_start=True)[0]

    # extract the player_start, which is not a wall
    walls.objects.remove(player_start)

    # construct the scene with a background layer color and the scrolling layers
    platformer_scene = cocos.scene.Scene()
    platformer_scene.add(layer.ColorLayer(100, 120, 150, 255), z=0)
    platformer_scene.add(scroller, z=1)

    # set focus 
    scroller.set_focus(300, 300)

    # handle zoom and pan commands
    director.window.push_handlers(on_key_press)

    # run the scene
    director.run(platformer_scene)