Create a gist now

Instantly share code, notes, and snippets.

ROFLBALT Building
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment