public
Created

ROFLBALT Building

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
class Building
include Renderable
def initialize x, y, width, background
@x, @y = x, y
@width = width
@background = background
@period = rand(4) + 6
@window_width = @period - rand(2) - 1
@color = (235..238).to_a.shuffle.first # Ruby 1.8
@top_color = @color + 4
@left_color = @color + 2
end
attr_reader :x, :y, :width
def move_left distance
@x -= distance
end
def height; SCREEN_HEIGHT - @y end
def pixel x, y, rx, ry, ticks
if ry == 0
if rx == width - 1
Pixel.new " "
else
Pixel.new "=", 234, @top_color
end
elsif rx == 0 || rx == 1
Pixel.new ":", @left_color + 1, @left_color
elsif rx == 2
Pixel.new ":", 236, 236
elsif rx == width - 1
Pixel.new ":", 236, 236
else
if rx % @period >= @period - @window_width && ry % 5 >= 2
Pixel.new(" ", 255, @background.color(rx + x/2, ry))
else
Pixel.new(":", 235, @color)
end
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.