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.
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/rofltim.rb', line 441 def initialize x, y, background @x, @y = x, y @background = background @frames = [ [ ' :TiM:TIM:TIM ', ' T ____|__ ', ' I ===` []\ ', ' M \________] ', ' .__|____|__/ ', ], [ ' TIM:TIM:tIm: ', ' ____|__ ', ' TIM===` []\ ', ' \________] ', ' .__|____|__/ ', ], ] end |
Instance Method Details
#char(rx, ry, ticks) ⇒ Object
474 475 476 477 478 |
# File 'lib/rofltim.rb', line 474 def char rx, ry, ticks @frames[ticks % 2][ry][rx] || " " rescue " " # Roflcopter crashes from time to time.. end |
#height ⇒ Object
462 |
# File 'lib/rofltim.rb', line 462 def height; 5 end |
#pixel(x, y, rx, ry, ticks) ⇒ Object
471 472 473 |
# File 'lib/rofltim.rb', line 471 def pixel x, y, rx, ry, ticks Pixel.new char(rx, ry, ticks), 246, @background.color(x, y) end |
#width ⇒ Object
461 |
# File 'lib/rofltim.rb', line 461 def width; 24 end |
#x ⇒ Object
467 468 469 470 |
# File 'lib/rofltim.rb', line 467 def x range = 20 @x + (range * Math.sin(Time.new.to_f * 0.7)).round end |
#y ⇒ Object
463 464 465 466 |
# File 'lib/rofltim.rb', line 463 def y range = 1.5 @y + (range * Math.sin(Time.new.to_f * 1.5)).round end |