[ create a new paste ] login | about

Link: http://codepad.org/AlpkRIGb    [ raw code | output | fork ]

Ruby, pasted on Jul 14:
$next_room = ''

class Engine

	def initialize(stage)
		@stage = stage
		puts "succesfully initialized game"
		@map = Map.new(@stage)
	end
end

class Map
	def initialize(start)
		@start = start
		#puts @start
		@rooms = {"roseroom" => method(:enterRose),
				"skullroom" => method(:enterSkull)
			}
		runner(@rooms, @start)
	end

	def runner(map, start)
		$next_room = start
		#puts @next_room
		while true
			
			room = map[$next_room]
			puts $next_room
			$next_room = room.call()
			#method(:enterSkull).call()
			
		end
	end

	def enterRose()
		@roseroom = Roseroom.new
	end

	def enterSkull()
		@skullroom = Skullroom.new
	end

end

class Roseroom
	def initialize
		puts "succesfully initialized roseroom"
		#$next_room = "skullroom"
		return "skullroom"
		
	end

	def exit
		
	end
end

class Skullroom
	def initialize
		puts "succesfully initialized skullroom"
		Process.exit(1)
	end
end

game = Engine.new("roseroom")


Output:
1
2
3
4
5
6
7
8
9
10
Line 29:in `runner': undefined method `call' for nil:NilClass (NoMethodError)
	from t.rb:19:in `initialize'
	from t.rb:8:in `new'
	from t.rb:8:in `initialize'
	from t.rb:65:in `new'
	from t.rb:65
succesfully initialized game
roseroom
succesfully initialized roseroom
#<Roseroom:0x401be62c>


Create a new paste based on this one


Comments: