Permalink
Browse files

Background created by World, not Background.

  • Loading branch information...
1 parent 24b9779 commit b7ac2bbd53b859801f8572c806b1adaf2fcc76e3 @pda committed Jan 16, 2012
Showing with 9 additions and 9 deletions.
  1. +9 −9 asc.rb
View
18 asc.rb
@@ -9,9 +9,8 @@ def initialize
end
def reset
@run = true
- background = Background.new
- @world = World.new(SCREEN_WIDTH, background)
- @screen = Screen.new(SCREEN_WIDTH, SCREEN_HEIGHT, @world, background)
+ @world = World.new(SCREEN_WIDTH)
+ @screen = Screen.new(SCREEN_WIDTH, SCREEN_HEIGHT, @world)
end
def run
Signal.trap(:INT) do
@@ -43,11 +42,11 @@ def on_exit
class Screen
OFFSET = -20
- def initialize width, height, world, background
+ def initialize width, height, world
@width = width
@height = height
@world = world
- @background = background
+ @background = world.background
create_frame_buffer
%x{stty -icanon -echo}
print "\033[0m" # reset
@@ -155,17 +154,18 @@ def size
end
class World
- def initialize horizon, background
+ def initialize horizon
@ticks = 0
@horizon = horizon
@building_generator = BuildingGenerator.new(self, WindowColor.new)
- @player = Player.new(25, background)
+ @background = Background.new
+ @player = Player.new(25, @background)
@buildings = [ @building_generator.build(-10, 30, 120) ]
- @misc = [ Scoreboard.new(self), RoflCopter.new(50, 4, background) ]
+ @misc = [ Scoreboard.new(self), RoflCopter.new(50, 4, @background) ]
@speed = 4
@distance = 0
end
- attr_reader :buildings, :player, :horizon, :speed, :misc, :ticks, :distance
+ attr_reader :buildings, :player, :horizon, :speed, :misc, :ticks, :distance, :background
def tick
# TODO: this, but less often.
if @ticks % 20 == 0

0 comments on commit b7ac2bb

Please sign in to comment.