class Tile

Attributes

angle[RW]
centre_point[R]
connections[RW]
details[RW]
image[RW]
pixel_x[R]
pixel_y[R]
x[R]
y[R]
z[RW]

Public Class Methods

new(x, y, size, details) click to toggle source
# File lib/gridmap.rb, line 171
def initialize(x, y, size, details)
        @x, @y, @size, @details = x, y, size, details
        @pixel_x      = @x * size
        @pixel_y      = @y * size
        
        @offset_x     = details[:offset_x] if details[:offset_x]
        @offset_y     = details[:offset_y] if details[:offset_y]
        @z                    = details[:z]            if details[:z]
        @angle                = details[:angle]     if details[:angle]

        @offset_x ||= 0
        @offset_y ||= 0
        @z ||= 0
        @angle ||= 0

        @centre_point = [@x * @size + @size / 2, @y * @size + @size / 2]
end

Public Instance Methods

draw() click to toggle source
# File lib/gridmap.rb, line 189
def draw
        if @details[:connected] || @details[:orientated]
                draw_rot
        else
                @image.draw @x * @size + @offset_x, @y * @size + @offset_y, @z
        end
end
draw_rot() click to toggle source
# File lib/gridmap.rb, line 197
def draw_rot
        @image.draw_rot @centre_point[0], @centre_point[1], @z, @angle
end