Skip to content

Instantly share code, notes, and snippets.

@ruprict
Created February 3, 2012 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruprict/1727010 to your computer and use it in GitHub Desktop.
Save ruprict/1727010 to your computer and use it in GitHub Desktop.
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