Sha256: 0f94ca8baa3b84cbba3c9f36602cad75e489982b1047c6c34bd250483812ef33
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 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 #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 def require_all_files Dir.foreach("#{SHATTERED_ROOT}/app/") do |type| next if File.file?("#{SHATTERED_ROOT}/app/#{type}") next if type =~ /view/ or type =~ /state/ Dir.foreach("#{SHATTERED_ROOT}/app/#{type}") do |file| require "#{SHATTERED_ROOT}/app/#{type}/#{file}" if file =~ /\.rb$/ end end end def run view = ShatteredView::Runner.new @environment view.add_to_environment @environment control = ShatteredController::Runner.new @environment ShatteredSupport::Configuration.environment=@environment puts "require '#{SHATTERED_ROOT}/app/states/#{@environment[:start_state].to_s}_state'" begin eval "require '#{SHATTERED_ROOT}/app/states/#{@environment[:start_state].to_s}_state'" rescue StandardError => output puts output.message end puts "creating #{@environment[:start_state].to_s.camelize}State.new" 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 | lib/game_loader.rb |