Class: Dopairb::Scene

Inherits:
Object
  • Object
show all
Defined in:
lib/dopairb/scene.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx, event = nil) ⇒ Scene

Returns a new instance of Scene.



56
57
58
59
60
61
62
# File 'lib/dopairb/scene.rb', line 56

def initialize(ctx, event = nil)
  @ctx = ctx
  @event = event
  @rng = ctx.rng
  @w = ctx.w
  setup
end

Instance Attribute Details

#ctx ⇒ Object (readonly)

Returns the value of attribute ctx.



54
55
56
# File 'lib/dopairb/scene.rb', line 54

def ctx
  @ctx
end

#event ⇒ Object (readonly)

Returns the value of attribute event.



54
55
56
# File 'lib/dopairb/scene.rb', line 54

def event
  @event
end

Instance Method Details

#alt? ⇒ Boolean

Played on the alternate screen (full screen, scrollback untouched).

Returns:

  • (Boolean)


71
# File 'lib/dopairb/scene.rb', line 71

def alt? = false

#bell? ⇒ Boolean

Returns:

  • (Boolean)


73
# File 'lib/dopairb/scene.rb', line 73

def bell? = mega?

#big? ⇒ Boolean

Returns:

  • (Boolean)


69
70
# File 'lib/dopairb/scene.rb', line 69

def big? = false
# Played on the alternate screen (full screen, scrollback untouched).

#depth ⇒ Object



97
# File 'lib/dopairb/scene.rb', line 97

def depth = ctx.depth

#done?(_t) ⇒ Boolean

Scenes that wait on something can end early.

Returns:

  • (Boolean)


85
# File 'lib/dopairb/scene.rb', line 85

def done?(_t) = false

#draw(_c, _t) ⇒ Object



94
# File 'lib/dopairb/scene.rb', line 94

def draw(_c, _t); end

#draw_top(c, t) ⇒ Object

Top rows (the input) as canvas, or nil to leave them untouched.



88
89
90
91
92
# File 'lib/dopairb/scene.rb', line 88

def draw_top(c, t)
  return nil unless t < pre
  glow_input(c, t / pre)
  true
end

#flash_at ⇒ Object



76
77
# File 'lib/dopairb/scene.rb', line 76

def flash_at = nil
# Sound patch name and when (scene time) its impact should be heard.

#height ⇒ Object



66
# File 'lib/dopairb/scene.rb', line 66

def height = 1

#impact_at ⇒ Object



79
# File 'lib/dopairb/scene.rb', line 79

def impact_at = flash_at || 0.0

#length ⇒ Object



67
# File 'lib/dopairb/scene.rb', line 67

def length = 0.4

#mega? ⇒ Boolean

Returns:

  • (Boolean)


72
# File 'lib/dopairb/scene.rb', line 72

def mega? = false

#paint(text, col, bold: false) ⇒ Object



99
100
101
102
# File 'lib/dopairb/scene.rb', line 99

def paint(text, col, bold: false)
  return text if depth == :none && !bold
  "#{Color.sgr(col, nil, bold, depth)}#{text}\e[0m"
end

#pre ⇒ Object

Wind-up before the main animation (input row glow); 0 when not wanted.



82
# File 'lib/dopairb/scene.rb', line 82

def pre = top? ? ctx.pre.to_f : 0.0

#setup ⇒ Object



64
# File 'lib/dopairb/scene.rb', line 64

def setup; end

#sfx ⇒ Object

Sound patch name and when (scene time) its impact should be heard.



78
# File 'lib/dopairb/scene.rb', line 78

def sfx = nil

#shake(_t) ⇒ Object



75
# File 'lib/dopairb/scene.rb', line 75

def shake(_t) = 0

#sub_bits(extra = []) ⇒ Object



104
105
106
107
108
109
110
111
112
113
# File 'lib/dopairb/scene.rb', line 104

def sub_bits(extra = [])
  bits = extra.dup
  return bits unless event
  bits << "+#{Fx.number_with_commas(event.gain)}" if event.gain.to_i > 0
  bits << "COMBO #{event.combo}" if event.combo.to_i > 1
  bits << "NEW RECORD" if event.flag?(:new_record) && !bits.include?("NEW RECORD")
  bits << "FIRST HIT" if event.flag?(:first_hit)
  bits << "RECOVERED after #{event.streak} error#{'s' if event.streak > 1}" if event.flag?(:comeback)
  bits
end

#sub_line(extra = []) ⇒ Object



115
116
117
# File 'lib/dopairb/scene.rb', line 115

def sub_line(extra = [])
  sub_bits(extra).join("   ")
end

#top? ⇒ Boolean

Returns:

  • (Boolean)


68
# File 'lib/dopairb/scene.rb', line 68

def top? = false

#total_length ⇒ Object



83
84
# File 'lib/dopairb/scene.rb', line 83

def total_length = pre + length
# Scenes that wait on something can end early.

#trail ⇒ Object



74
# File 'lib/dopairb/scene.rb', line 74

def trail = nil

#w ⇒ Object



96
# File 'lib/dopairb/scene.rb', line 96

def w = @w