Class: RoflCopter

Inherits:
Object
  • Object
show all
Includes:
Renderable
Defined in:
lib/roflbalt.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.



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

#heightObject



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

#widthObject



459
# File 'lib/roflbalt.rb', line 459

def width; 24 end

#xObject



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

#yObject



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