Class: Doom::Wad::HudGraphics
- Inherits:
-
Object
- Object
- Doom::Wad::HudGraphics
- Defined in:
- lib/doom/wad/hud_graphics.rb
Overview
Loads HUD graphics (status bar, weapons) from WAD
Instance Attribute Summary collapse
-
#arms_background ⇒ Object
readonly
Returns the value of attribute arms_background.
-
#faces ⇒ Object
readonly
Returns the value of attribute faces.
-
#grey_numbers ⇒ Object
readonly
Returns the value of attribute grey_numbers.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#numbers ⇒ Object
readonly
Returns the value of attribute numbers.
-
#status_bar ⇒ Object
readonly
Returns the value of attribute status_bar.
-
#weapons ⇒ Object
readonly
Returns the value of attribute weapons.
-
#yellow_numbers ⇒ Object
readonly
Returns the value of attribute yellow_numbers.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Get a cached graphic by name.
-
#initialize(wad) ⇒ HudGraphics
constructor
A new instance of HudGraphics.
-
#load_graphic(name) ⇒ Object
Load (and cache) a single named patch/graphic lump.
Constructor Details
#initialize(wad) ⇒ HudGraphics
Returns a new instance of HudGraphics.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/doom/wad/hud_graphics.rb', line 9 def initialize(wad) @wad = wad @cache = {} load_numbers load_weapons load_faces load_keys end |
Instance Attribute Details
#arms_background ⇒ Object (readonly)
Returns the value of attribute arms_background.
7 8 9 |
# File 'lib/doom/wad/hud_graphics.rb', line 7 def arms_background @arms_background end |
#faces ⇒ Object (readonly)
Returns the value of attribute faces.
7 8 9 |
# File 'lib/doom/wad/hud_graphics.rb', line 7 def faces @faces end |
#grey_numbers ⇒ Object (readonly)
Returns the value of attribute grey_numbers.
7 8 9 |
# File 'lib/doom/wad/hud_graphics.rb', line 7 def grey_numbers @grey_numbers end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
7 8 9 |
# File 'lib/doom/wad/hud_graphics.rb', line 7 def keys @keys end |
#numbers ⇒ Object (readonly)
Returns the value of attribute numbers.
7 8 9 |
# File 'lib/doom/wad/hud_graphics.rb', line 7 def numbers @numbers end |
#status_bar ⇒ Object (readonly)
Returns the value of attribute status_bar.
7 8 9 |
# File 'lib/doom/wad/hud_graphics.rb', line 7 def end |
#weapons ⇒ Object (readonly)
Returns the value of attribute weapons.
7 8 9 |
# File 'lib/doom/wad/hud_graphics.rb', line 7 def weapons @weapons end |
#yellow_numbers ⇒ Object (readonly)
Returns the value of attribute yellow_numbers.
7 8 9 |
# File 'lib/doom/wad/hud_graphics.rb', line 7 def yellow_numbers @yellow_numbers end |
Instance Method Details
#[](name) ⇒ Object
Get a cached graphic by name
21 22 23 |
# File 'lib/doom/wad/hud_graphics.rb', line 21 def [](name) @cache[name] end |
#load_graphic(name) ⇒ Object
Load (and cache) a single named patch/graphic lump. Returns a HudSprite or nil if the lump is missing or too small. Public so the menu, intermission and font renderers can pull graphics by name.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/doom/wad/hud_graphics.rb', line 28 def load_graphic(name) return @cache[name] if @cache[name] entry = @wad.find_lump(name) return nil unless entry data = @wad.read_lump_at(entry) return nil unless data && data.size > 8 sprite = parse_patch(name, data) @cache[name] = sprite sprite end |