Sha256: dace2914c4f132b4b992dca6f0acee980cb61a6036632c777484dd042d4982a6

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'singleton'

begin
  require 'shattered_controller'
rescue LoadError
  require 'rubygems'
  require 'shattered_controller'
end
require 'shattered_view'
require 'shattered_model'

include ShatteredController
include ShatteredView
include ShatteredModel

module Shatter #:nodoc:all
#This class is loads the view, controller, and model.  It then loads
#and starts the game based on these.
class GameLoader
	include Singleton
	attr_writer :environment
	
	# This will recourse into the app/** directories and load all ruby files inside those directories.
  def load_all_sources(shattered_root)
    File.find_by_extension(shattered_root+"/app", "rb").each do |file|
      require(file)
    end
  end
	def run
		view = ShatteredView::Runner.new @environment
		view.add_to_environment @environment
		control = ShatteredController::Runner.new(@environment)
		ShatteredSupport::Configuration.environment=@environment
		load_all_sources(SHATTERED_ROOT)
		
    begin
      require "#{SHATTERED_ROOT}/app/states/#{@environment[:start_state].to_s}_state"
    rescue StandardError => output
      puts output.message
    end
		
		eval("#{@environment[:start_state].to_s.camelize}State").new
		control.start_game
	end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shattered-0.3.2 lib/game_loader.rb