Class: Doom::Game::SectorEffects::LightFlash

Inherits:
Object
  • Object
show all
Defined in:
lib/doom/game/sector_effects.rb

Overview

T_LightFlash (type 1): mostly bright with brief random dark flickers

Instance Method Summary collapse

Constructor Details

#initialize(sector, minlight) ⇒ LightFlash

Returns a new instance of LightFlash.



85
86
87
88
89
90
# File 'lib/doom/game/sector_effects.rb', line 85

def initialize(sector, minlight)
  @sector = sector
  @maxlight = sector.light_level
  @minlight = minlight
  @count = (rand(65)) + 1
end

Instance Method Details

#updateObject



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/doom/game/sector_effects.rb', line 92

def update
  @count -= 1
  return if @count > 0

  if @sector.light_level == @maxlight
    @sector.light_level = @minlight
    @count = (rand(8)) + 1       # dark for 1-8 tics
  else
    @sector.light_level = @maxlight
    @count = (rand(2) == 0 ? 1 : 65)  # bright for 1 or 65 tics (P_Random()&64)
  end
end