samples/99_genre_rpg_roguelike/02_roguelike_line_of_sight/app/main.rb
def derive_dungeon_from_area
    state.dungeon = [] # starts as empty collection

    state.area.each do |a| # for each element of the area collection
      state.dungeon << state.new_entity(:dungeon_cell) do |d| # declares each dungeon cell as new entity
        d.x = a.x # dungeon cell position using coordinates from area
        d.y = a.y
        d.is_visible = false # cell is not visible
        d.alpha = 0 # not transparent at all
        d.border = [left_margin   + a.x * grid_size,
                    bottom_margin + a.y * grid_size,
                    grid_size,
                    grid_size,
                    *blue,
                    255] # sets border definition for dungeon cell
        d # returns dungeon cell
      end
    end
  end
# Starts with an empty dungeon collection, and adds dungeon cells into it.
Starts with an empty dungeon collection, and adds dungeon cells into it.
Starts with an empty dungeon collection and adds dungeon cells into it .
def derive_dungeon_from_area
    state.dungeon = [] 
    state.area.each do |a| 
      state.dungeon << state.new_entity(:dungeon_cell) do |d| 
        d.x = a.x 
        d.y = a.y
        d.is_visible = false 
        d.alpha = 0 
        d.border = [left_margin   + a.x * grid_size,
                    bottom_margin + a.y * grid_size,
                    grid_size,
                    grid_size,
                    *blue,
                    255] 
        d 
      end
    end
  end
def derive_dungeon_from_area state . dungeon = [ ] state . area . each do | a | state . dungeon << state . new_entity ( :dungeon_cell ) do | d | d . x = a . x d . y = a . y d . is_visible = false d . alpha = 0 d . border = [ left_margin + a . x * grid_size , bottom_margin + a . y * grid_size , grid_size , grid_size , * blue , 255 ] d end end end
Starts with an empty dungeon collection, and adds dungeon cells into it.
Starts with an empty dungeon collection and adds dungeon cells into it .
# starts as empty collection # for each element of the area collection # declares each dungeon cell as new entity # dungeon cell position using coordinates from area # cell is not visible # not transparent at all # sets border definition for dungeon cell # returns dungeon cell