Class: HarlemBits::Harlem
- Inherits:
-
Object
- Object
- HarlemBits::Harlem
- Defined in:
- lib/harlem_bits/harlem.rb
Instance Method Summary collapse
-
#initialize(width, height) ⇒ Harlem
constructor
A new instance of Harlem.
- #kill ⇒ Object
- #start ⇒ Object
Constructor Details
Instance Method Details
#kill ⇒ Object
8 9 10 |
# File 'lib/harlem_bits/harlem.rb', line 8 def kill @alive = false end |
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/harlem_bits/harlem.rb', line 12 def start start_t = Time.now.to_f last_t = Time.now.to_i frame = 0 switched = false while @alive cur_t = Time.now.to_f delta = cur_t - start_t @arena.clear @arena.center.switch if delta % 2.0 == 0 || (delta % 2.0) / 2.0 > 0.3 @arena.random! if delta >= (DURATION / 2) + 1 @arena.draw break if delta > DURATION sleep 1/FRAME_RATE end end |