Created
February 3, 2012 01:25
-
-
Save ruprict/1727010 to your computer and use it in GitHub Desktop.
ROFLBALT RoflCopter
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 RoflCopter | |
include Renderable | |
def initialize x, y, background | |
@x, @y = x, y | |
@background = background | |
@frames = [ | |
[ | |
' :LoL:ROFL:ROFL', | |
' L ____|__ ', | |
' O ===` []\ ', | |
' L \________] ', | |
' .__|____|__/ ', | |
], | |
[ | |
' ROFL:ROFL:LoL: ', | |
' ____|__ ', | |
' LOL===` []\ ', | |
' \________] ', | |
' .__|____|__/ ', | |
], | |
] | |
end | |
def width; 24 end | |
def height; 5 end | |
def y | |
range = 1.5 | |
@y + (range * Math.sin(Time.new.to_f * 1.5)).round | |
end | |
def x | |
range = 20 | |
@x + (range * Math.sin(Time.new.to_f * 0.7)).round | |
end | |
def pixel x, y, rx, ry, ticks | |
Pixel.new char(rx, ry, ticks), 246, @background.color(x, y) | |
end | |
def char rx, ry, ticks | |
@frames[ticks % 2][ry][rx] || " " | |
rescue | |
" " # Roflcopter crashes from time to time.. | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment