Class: Background
- Inherits:
-
Object
- Object
- Background
- Defined in:
- lib/roflbalt.rb
Constant Summary collapse
- PALETTE =
[ 16, 232, 233 ]
- PERIOD =
16.0
- SPEED =
0.5
- BLOCKINESS =
10.0
Instance Method Summary collapse
- #color(x, y) ⇒ Object
-
#initialize(world) ⇒ Background
constructor
A new instance of Background.
- #pixel(x, y, char = " ") ⇒ Object
Constructor Details
#initialize(world) ⇒ Background
Returns a new instance of Background.
118 119 120 |
# File 'lib/roflbalt.rb', line 118 def initialize world @world = world end |
Instance Method Details
#color(x, y) ⇒ Object
124 125 126 127 128 |
# File 'lib/roflbalt.rb', line 124 def color x, y y = (y / BLOCKINESS).round * BLOCKINESS sin = Math.sin((x + @world.distance.to_f * SPEED) / PERIOD + y / PERIOD) PALETTE[(0.9 * sin + 0.9).round] end |