Class: Dopairb::Scenes::Loading
- Inherits:
-
Dopairb::Scene
- Object
- Dopairb::Scene
- Dopairb::Scenes::Loading
- Defined in:
- lib/dopairb/scenes/session.rb
Overview
Shown at startup while the startup sound is being synthesized. A cat runs along a pastel progress bar; LOADING bounces; sparkles pop.
Constant Summary collapse
- PASTEL =
[[255, 170, 210], [255, 205, 160], [255, 245, 170], [180, 245, 200], [170, 215, 255], [215, 185, 255]].freeze
- MESSAGES =
["tuning the synthesizer", "polishing sparkles", "charging the combo meter", "stacking fireworks", "waking up the cat"].freeze
- MIN =
0.7- FINISH =
0.45
Instance Attribute Summary
Attributes inherited from Dopairb::Scene
Instance Method Summary collapse
- #done?(t) ⇒ Boolean
- #draw(c, t) ⇒ Object
- #height ⇒ Object
-
#initialize(ctx, ready) ⇒ Loading
constructor
A new instance of Loading.
-
#length ⇒ Object
safety net; normally ends via done?.
- #pastel(i, t) ⇒ Object
- #progress(t) ⇒ Object
- #setup ⇒ Object
Methods inherited from Dopairb::Scene
#alt?, #bell?, #big?, #depth, #draw_top, #flash_at, #impact_at, #mega?, #paint, #pre, #sfx, #shake, #sub_bits, #sub_line, #top?, #total_length, #trail, #w
Constructor Details
#initialize(ctx, ready) ⇒ Loading
Returns a new instance of Loading.
162 163 164 165 166 |
# File 'lib/dopairb/scenes/session.rb', line 162 def initialize(ctx, ready) @ready = ready @ready_at = nil super(ctx, nil) end |
Instance Method Details
#done?(t) ⇒ Boolean
177 178 179 180 181 182 183 |
# File 'lib/dopairb/scenes/session.rb', line 177 def done?(t) if @ready_at.nil? && t >= MIN && @ready.call @ready_at = t @parts.burst(@bar_x + @bar_w, 3, 40, at: t, speed: 40, life: 0.5, palette: PASTEL, gravity: 10) end @ready_at && t >= @ready_at + FINISH end |
#draw(c, t) ⇒ Object
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/dopairb/scenes/session.rb', line 193 def draw(c, t) Fx.sparkles(c, t, 21, 18, palette: PASTEL.reverse) draw_word(c, t) (c, t) @parts.draw(c, t) msg = if @ready_at then "ready! #{Term.glyph('✦', '*')}" else "#{MESSAGES[(t / 0.9).to_i % MESSAGES.size]}#{'.' * ((t * 4).to_i % 4)}" end c.put(@bar_x, 5, msg, @ready_at ? [255, 240, 170] : [200, 190, 230], bold: !@ready_at.nil?) end |
#height ⇒ Object
168 |
# File 'lib/dopairb/scenes/session.rb', line 168 def height = 6 |
#length ⇒ Object
safety net; normally ends via done?
169 |
# File 'lib/dopairb/scenes/session.rb', line 169 def length = 8.0 # safety net; normally ends via done? |
#pastel(i, t) ⇒ Object
191 |
# File 'lib/dopairb/scenes/session.rb', line 191 def pastel(i, t) = Color.ramp(PASTEL, ((i * 0.13 + t * 0.6) % 1.0)) |