Class: HarlemBits::Arena
- Inherits:
-
Object
- Object
- HarlemBits::Arena
- Includes:
- CliRendering
- Defined in:
- lib/harlem_bits/arena.rb
Constant Summary
Constants included from CliRendering
Instance Method Summary collapse
- #center ⇒ Object
- #clear ⇒ Object
-
#initialize(width, height) ⇒ Arena
constructor
A new instance of Arena.
- #random ⇒ Object
- #random! ⇒ Object
Methods included from CliRendering
Constructor Details
Instance Method Details
#center ⇒ Object
14 15 16 |
# File 'lib/harlem_bits/arena.rb', line 14 def center @arena[@height/2][@width/2] end |
#clear ⇒ Object
18 19 20 |
# File 'lib/harlem_bits/arena.rb', line 18 def clear @arena.each { |row| row.each { |bit| bit.off } } end |
#random ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/harlem_bits/arena.rb', line 26 def random found = [] @arena.each do |row| row.each do |bit| found << bit if rand(@width) < @width/3 end end found end |
#random! ⇒ Object
22 23 24 |
# File 'lib/harlem_bits/arena.rb', line 22 def random! random.map { |bit| bit.switch } end |