public
Created

ROFLBALT Background

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class Background
PALETTE = [ 16, 232, 233 ]
PERIOD = 16.0
SPEED = 0.5
BLOCKINESS = 10.0
def initialize world
@world = world
end
def pixel x, y, char = " "
Pixel.new char, 0, color(x, y)
end
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
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.