Skip to content
This repository has been archived by the owner on Sep 13, 2019. It is now read-only.

Enhance tiled map API #37

Open
zacharycarter opened this issue May 23, 2017 · 1 comment
Open

Enhance tiled map API #37

zacharycarter opened this issue May 23, 2017 · 1 comment

Comments

@zacharycarter
Copy link
Member

Tiled map API is very basic.

Add additional procs for -
know / get the size (AABB)
translate it on render?

Also -
provide way to render w/o calling begin and end on spritebatch

@zacharycarter
Copy link
Member Author

proc newTiledMapComponent*(): TiledMapComponent =
    return TiledMapComponent()

proc source*(self: TiledMapComponent): TiledMap =
    return self.source

proc `source=`*(self: TiledMapComponent, value: TiledMap) =
    self.source = value
    # when the user changes the tiledmap, recalculate its bounds
    self.markAabbDirty()

method calcAabb*(self: TiledMapComponent): Rectangle =

    if self.source == nil:
        # 0,0,0,0
        return

    # TODO: calculate the total size
    return Rectangle(
        x: 0, y: 0,
        width: 1000,
        height: 1000
    )

method render*(self: TiledMapComponent, context: RenderContext) =

    if self.source == nil:
        return

    let position = absolutePosition(self.node)

    # hack
    context.batch.`end`()

    # TODO: translate the map
    self.source.render(context.batch, context.camera)

    context.batch.begin()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant