Sha256: 072a18c3d30217ed5edd6ad32a0b271b157d7288825ad0d911748f793eb40c77

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

Contents

require 'singleton'

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
		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 = ShatteredController::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 lib/game_loader.rb