Skip to content

Instantly share code, notes, and snippets.

@ruprict
Created February 3, 2012 00:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ruprict/1726822 to your computer and use it in GitHub Desktop.
ROFLBALT
SCREEN_WIDTH = 120
SCREEN_HEIGHT = 40
class Game
def initialize
reset
end
def reset
@run = true
@world = World.new(SCREEN_WIDTH)
@screen = Screen.new(SCREEN_WIDTH, SCREEN_HEIGHT, @world)
end
def run
Signal.trap(:INT) do
@run = false
end
while @run
start_time = Time.new.to_f
unless @world.tick
reset
end
render start_time
end
on_exit
end
def render start_time
@world.buildings.each do |building|
@screen.draw(building)
end
@screen.draw(@world.player)
@world.misc.each do |object|
@screen.draw(object)
end
@screen.render start_time
end
def on_exit
@screen.on_exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment