Class: RoflCopter
Instance Method Summary collapse
- #char(rx, ry, ticks) ⇒ Object
- #height ⇒ Object
-
#initialize(x, y, background) ⇒ RoflCopter
constructor
A new instance of RoflCopter.
- #pixel(x, y, rx, ry, ticks) ⇒ Object
- #width ⇒ Object
- #x ⇒ Object
- #y ⇒ Object
Methods included from Renderable
Constructor Details
#initialize(x, y, background) ⇒ RoflCopter
Returns a new instance of RoflCopter.
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/roflbalt.rb', line 439 def initialize x, y, background @x, @y = x, y @background = background @frames = [ [ ' :LoL:ROFL:ROFL', ' L ____|__ ', ' O ===` []\ ', ' L \________] ', ' .__|____|__/ ', ], [ ' ROFL:ROFL:LoL: ', ' ____|__ ', ' LOL===` []\ ', ' \________] ', ' .__|____|__/ ', ], ] end |
Instance Method Details
#char(rx, ry, ticks) ⇒ Object
472 473 474 475 476 |
# File 'lib/roflbalt.rb', line 472 def char rx, ry, ticks @frames[ticks % 2][ry][rx] || " " rescue " " # Roflcopter crashes from time to time.. end |
#height ⇒ Object
460 |
# File 'lib/roflbalt.rb', line 460 def height; 5 end |
#pixel(x, y, rx, ry, ticks) ⇒ Object
469 470 471 |
# File 'lib/roflbalt.rb', line 469 def pixel x, y, rx, ry, ticks Pixel.new char(rx, ry, ticks), 246, @background.color(x, y) end |
#width ⇒ Object
459 |
# File 'lib/roflbalt.rb', line 459 def width; 24 end |
#x ⇒ Object
465 466 467 468 |
# File 'lib/roflbalt.rb', line 465 def x range = 20 @x + (range * Math.sin(Time.new.to_f * 0.7)).round end |
#y ⇒ Object
461 462 463 464 |
# File 'lib/roflbalt.rb', line 461 def y range = 1.5 @y + (range * Math.sin(Time.new.to_f * 1.5)).round end |