Class: Doom::Wad::Flat
- Inherits:
-
Object
- Object
- Doom::Wad::Flat
- Defined in:
- lib/doom/wad/flat.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pixels ⇒ Object
readonly
Returns the value of attribute pixels.
Class Method Summary collapse
Instance Method Summary collapse
- #[](x, y) ⇒ Object
- #height ⇒ Object
-
#initialize(name, pixels) ⇒ Flat
constructor
A new instance of Flat.
- #width ⇒ Object
Constructor Details
#initialize(name, pixels) ⇒ Flat
Returns a new instance of Flat.
20 21 22 23 |
# File 'lib/doom/wad/flat.rb', line 20 def initialize(name, pixels) @name = name @pixels = pixels end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/doom/wad/flat.rb', line 10 def name @name end |
#pixels ⇒ Object (readonly)
Returns the value of attribute pixels.
10 11 12 |
# File 'lib/doom/wad/flat.rb', line 10 def pixels @pixels end |
Class Method Details
.load_all(wad) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/doom/wad/flat.rb', line 29 def self.load_all(wad) entries = wad.lumps_between('F_START', 'F_END') entries.map do |entry| next if entry.size != SIZE data = wad.read_lump_at(entry) new(entry.name, data.bytes) end.compact end |
Instance Method Details
#[](x, y) ⇒ Object
25 26 27 |
# File 'lib/doom/wad/flat.rb', line 25 def [](x, y) @pixels[(y & 63) * WIDTH + (x & 63)] end |
#height ⇒ Object
16 17 18 |
# File 'lib/doom/wad/flat.rb', line 16 def height HEIGHT end |
#width ⇒ Object
12 13 14 |
# File 'lib/doom/wad/flat.rb', line 12 def width WIDTH end |