Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Building doesn't subclass Struct, has #move_left method.

  • Loading branch information...
commit 52379193dd352646a471f44aa7e1465e613a9222 1 parent eb64ef1
@pda authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 asc.rb
View
13 asc.rb
@@ -141,12 +141,12 @@ def tick
@distance += speed
buildings.each do |b|
- b.x -= speed
+ b.move_left speed
end
if b = building_under_player
if player.bottom_y > b.y
- b.x += speed
+ b.move_left(-speed)
@speed = 0
@misc << Blood.new(player.x, player.y)
@misc << GameOverBanner.new
@@ -218,16 +218,21 @@ def each_pixel ticks
def right_x; x + width end
end
-class Building < Struct.new(:x, :y, :width)
+class Building
include Renderable
def initialize x, y, width
- super
+ @x, @y = x, y
+ @width = width
@period = rand(4) + 6
@window_width = @period - rand(2) - 1
@color = (235..238).to_a.sample
@top_color = @color + 4
@left_color = @color + 2
end
+ attr_reader :x, :y, :width
+ def move_left distance
+ @x -= distance
+ end
def height; 20 end
def pixel x, y, rx, ry, ticks
if ry == 0
Please sign in to comment.
Something went wrong with that request. Please try again.