Created
February 3, 2012 01:10
-
-
Save ruprict/1726875 to your computer and use it in GitHub Desktop.
ROFLBALT Background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment