Class: RoflCopter

Inherits:
Object
  • Object
show all
Includes:
Renderable
Defined in:
lib/rofltim.rb

Instance Method Summary collapse

Methods included from Renderable

#each_pixel, #right_x

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

#heightObject



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

#widthObject



461
# File 'lib/rofltim.rb', line 461

def width; 24 end

#xObject



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

#yObject



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