Skip to content

Commit

Permalink
Background created by World, not Background.
Browse files Browse the repository at this point in the history
  • Loading branch information
pda committed Jan 16, 2012
1 parent 24b9779 commit b7ac2bb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions asc.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b7ac2bb

Please sign in to comment.