Method: MiniGL::Map#foreach
- Defined in:
- lib/minigl/map.rb
#foreach ⇒ Object
Iterates through the currently visible tiles, providing the horizontal tile index, the vertical tile index, the x-coordinate (in pixels) and the y-coordinate (in pixels), of each tile, in that order, to a given block of code.
Example:
map.foreach do |i, j, x, y|
draw_tile tiles[i][j], x, y
end
141 142 143 144 145 146 147 148 |
# File 'lib/minigl/map.rb', line 141 def foreach for j in @min_vis_y..@max_vis_y for i in @min_vis_x..@max_vis_x pos = get_screen_pos i, j yield i, j, pos.x, pos.y end end end |