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, random) ⇒ LightFlash



89
90
91
92
93
94
95
# File 'lib/doom/game/sector_effects.rb', line 89

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

Instance Method Details

#updateObject



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/doom/game/sector_effects.rb', line 97

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

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