Class: Doom::Wad::CompositeTexture

Inherits:
Object
  • Object
show all
Defined in:
lib/doom/wad/texture.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, width, height, columns) ⇒ CompositeTexture

Returns a new instance of CompositeTexture.



140
141
142
143
144
145
# File 'lib/doom/wad/texture.rb', line 140

def initialize(name, width, height, columns)
  @name = name
  @width = width
  @height = height
  @columns = columns
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



138
139
140
# File 'lib/doom/wad/texture.rb', line 138

def columns
  @columns
end

#heightObject (readonly)

Returns the value of attribute height.



138
139
140
# File 'lib/doom/wad/texture.rb', line 138

def height
  @height
end

#nameObject (readonly)

Returns the value of attribute name.



138
139
140
# File 'lib/doom/wad/texture.rb', line 138

def name
  @name
end

#widthObject (readonly)

Returns the value of attribute width.



138
139
140
# File 'lib/doom/wad/texture.rb', line 138

def width
  @width
end

Instance Method Details

#column_pixels(x, height_needed = nil) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/doom/wad/texture.rb', line 147

def column_pixels(x, height_needed = nil)
  x = x % @width
  posts = @columns[x]
  height_needed ||= @height

  pixels = Array.new(height_needed, 0)
  posts.each do |post|
    post.pixels.each_with_index do |color, i|
      y = (post.top_delta + i) % @height
      pixels[y] = color if y < height_needed
    end
  end
  pixels
end