Class: Doom::Game::SectorEffects::Glow

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

Overview

T_Glow (type 8): smooth triangle-wave oscillation

Instance Method Summary collapse

Constructor Details

#initialize(sector, minlight) ⇒ Glow

Returns a new instance of Glow.



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

def initialize(sector, minlight)
  @sector = sector
  @maxlight = sector.light_level
  @minlight = minlight
  @direction = -1 # start dimming
end

Instance Method Details

#updateObject



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

def update
  if @direction == -1
    @sector.light_level -= GLOWSPEED
    if @sector.light_level <= @minlight
      @sector.light_level += GLOWSPEED
      @direction = 1
    end
  else
    @sector.light_level += GLOWSPEED
    if @sector.light_level >= @maxlight
      @sector.light_level -= GLOWSPEED
      @direction = -1
    end
  end
end