Class: Dopairb::Scenes::Rain

Inherits:
Dopairb::Scene show all
Defined in:
lib/dopairb/scenes/success.rb

Overview

Floods of stdout: digital rain behind a counter.

Instance Attribute Summary

Attributes inherited from Dopairb::Scene

#ctx, #event

Instance Method Summary collapse

Methods inherited from Dopairb::Scene

#alt?, #bell?, #depth, #done?, #draw_top, #flash_at, #impact_at, #initialize, #mega?, #paint, #pre, #shake, #sub_bits, #sub_line, #top?, #total_length, #w

Constructor Details

This class inherits a constructor from Dopairb::Scene

Instance Method Details

#big? ⇒ Boolean



401
# File 'lib/dopairb/scenes/success.rb', line 401

def big? = true

#draw(c, t) ⇒ Object



408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# File 'lib/dopairb/scenes/success.rb', line 408

def draw(c, t)
  @cols.each_with_index do |(off, speed, kind), x|
    next if kind == 2
    head = (t * speed - off) % (height + 6)
    6.times do |k|
      y = (head - k).floor
      next if y < 0 || y >= height
      ch = @chars[(x * 7 + y * 13 + (t * 20).to_i) % @chars.size]
      col = k.zero? ? [230, 255, 230] : Color.ramp(Color::TOXIC, k / 6.0 + 0.1)
      c.put(x, y, ch, col, bold: k.zero?)
    end
  end
  label = "  OUTPUT RAIN  x#{Fx.number_with_commas(event.info[:out_lines] || 0)} LINES  "
  x = (@w - label.size) / 2
  c.fill_bg([0, 40, 10], x, 2, label.size, 1)
  c.put(x, 2, label, [180, 255, 180], bold: true)
end

#height ⇒ Object



399
# File 'lib/dopairb/scenes/success.rb', line 399

def height = 5

#length ⇒ Object



400
# File 'lib/dopairb/scenes/success.rb', line 400

def length = 0.9

#setup ⇒ Object



403
404
405
406
# File 'lib/dopairb/scenes/success.rb', line 403

def setup
  @cols = Array.new(@w) { [@rng.rand * 5, 6 + @rng.rand * 14, @rng.rand(3)] }
  @chars = ("0".."9").to_a + ("a".."z").to_a + %w[{ } ( ) < > = ; :]
end

#sfx ⇒ Object



398
# File 'lib/dopairb/scenes/success.rb', line 398

def sfx = :rain

#trail ⇒ Object



426
# File 'lib/dopairb/scenes/success.rb', line 426

def trail = paint("#{Term.glyph('✦', '*')} OUTPUT RAIN x#{event.info[:out_lines]} lines", [120, 230, 140], bold: true)