class SK::MapRenderer

Attributes

images[RW]

Public Class Methods

new(images) click to toggle source
# File lib/shirokuro/standard_components/rendering/map_renderer.rb, line 6
def initialize images
        @images = images
end

Public Instance Methods

draw(context) click to toggle source
# File lib/shirokuro/standard_components/rendering/map_renderer.rb, line 17
def draw context
        map = @map.map

        map.layers.each do |layer|
                if layer.type == "tilelayer" && layer.visible
                        layer.width.times do |col|
                                layer.height.times do |row|
                                        cell = layer.get(col, row)
                                        if cell > -1
                                                @images[cell].draw(
                                                        transform.position.x + (map.tile_width * col), 
                                                        transform.position.y + (map.tile_height * row), 0, 1, 1, layer.color)
                                        end
                                end
                        end
                end
        end
end
start() click to toggle source
# File lib/shirokuro/standard_components/rendering/map_renderer.rb, line 10
def start
        @map = get_component(MapComponent)
        if @map == nil
                raise "MapComponent required for MapRenderer"
        end
end