Sha256: 18d529384e55ce7a0127849fa63b1bac82b21e6e527b31aa4055edf145d53661

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

require 'singleton'

include ShatteredState
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
		load_environment
		load_all_sources(SHATTERED_ROOT)
		
		eval("#{@environment[:start_state].to_s.camelize}State").new

		@control.start_game(@environment)
	end
	def load_environment
	  view = ShatteredView::Runner.new @environment
		view.add_to_environment @environment
		@control = ShatteredState::Runner.new(@environment)
		ShatteredPack::Configuration.environment=@environment
		return @environment
	end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shattered-0.4.0.1 lib/game_loader.rb