Create a gist now

Instantly share code, notes, and snippets.

ROFLBALT RoflCopter
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