class DXRuby::Tiled::OrthogonalLayer
Public Class Methods
pixel_height(map)
click to toggle source
# File lib/dxruby_tiled/layer_orthogonal.rb, line 54 def self.pixel_height(map) map.tile_height * map.height end
pixel_width(map)
click to toggle source
# File lib/dxruby_tiled/layer_orthogonal.rb, line 50 def self.pixel_width(map) map.tile_width * map.width end
Public Instance Methods
at(pos_x, pos_y)
click to toggle source
# File lib/dxruby_tiled/layer_orthogonal.rb, line 32 def at(pos_x, pos_y) self[pos_x.to_i / @tile_width, pos_y.to_i / @tile_height] end
change_at(pos_x, pos_y, value)
click to toggle source
# File lib/dxruby_tiled/layer_orthogonal.rb, line 36 def change_at(pos_x, pos_y, value) self[pos_x.to_i / @tile_width, pos_y.to_i / @tile_height] = value end
draw(pos_x, pos_y, target = DXRuby::Window, z = 0, offset_x = 0, offset_y = 0, opacity = 1.0)
Alias for: render
render(pos_x, pos_y, target = DXRuby::Window, z = 0, offset_x = 0, offset_y = 0, opacity = 1.0)
click to toggle source
Calls superclass method
# File lib/dxruby_tiled/layer_orthogonal.rb, line 4 def render(pos_x, pos_y, target = DXRuby::Window, z = 0, offset_x = 0, offset_y = 0, opacity = 1.0) super pos_x, pos_y = 0, 0 if @fixed off_x = offset_x + @offset_x - pos_x off_y = offset_y + @offset_y - pos_y x1, y1 = xy_at(@tile_width - @tilesets.tile_right - off_x, @tile_height - @tilesets.tile_bottom - off_y) x2, y2 = xy_at(@render_target.width - @tilesets.tile_left - off_x - 1, @render_target.height - @tilesets.tile_top - off_y - 1) (y1..(y2 + 1)).public_send(@renderorder_y ? :each : :reverse_each) do |y| (x1..(x2 + 1)).public_send(@renderorder_x ? :each : :reverse_each) do |x| @tilesets[self[x, y]].render( x * @tile_width + off_x, y * @tile_height + off_y, @render_target) end end target.draw_alpha(0, 0, @render_target, @opacity * 255, z + @z_index) end
Also aliased as: draw
vertexs(x, y)
click to toggle source
# File lib/dxruby_tiled/layer_orthogonal.rb, line 40 def vertexs(x, y) w, h = @tile_width, @tile_height return [ [ x * w , y * h ], [ x * w , y * h + h ], [ x * w + w, y * h + h ], [ x * w + w, y * h ] ] end
xy_at(pos_x, pos_y)
click to toggle source
# File lib/dxruby_tiled/layer_orthogonal.rb, line 28 def xy_at(pos_x, pos_y) return pos_x.to_i / @tile_width, pos_y.to_i / @tile_height end