Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Adventure

By: a guest on May 21st, 2013  |  syntax: None  |  size: 1.58 KB  |  views: 80  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class Room
  2.     attr_accessor :contents, :description
  3. end
  4.  
  5. class Contents
  6.     attr_accessor :contents
  7.     def initialize contents
  8.         @contents = contents
  9.     end
  10. end
  11.  
  12. class Player
  13.     attr_accessor :inventory
  14. end
  15.  
  16. class Map
  17.     def initialize
  18.         airlock1 = Room.new
  19.         airlock1.description = "The airlock of a space station. It contains:"
  20.         airlock1.contents = Contents.new ["Spacesuit", "Clipboard", "Flashlight"]
  21.  
  22.         science_lab = Room.new
  23.         science_lab.description = "You're in the science lab. It contains:"
  24.         science_lab.contents = Contents.new ["Plasma Cutter", "Chemicals", "USB Drive"]
  25.  
  26.         mess_hall = Room.new
  27.         mess_hall.description = "You're in the mess hall. It contains:"
  28.  
  29.         crew_quarters = Room.new
  30.         crew_quarters.description = "You're in the crew quarters. It contains:"
  31.  
  32.         @map = [[airlock1, science_lab],[mess_hall, crew_quarters]]
  33.         @current_room_position = [0,0]
  34.     end
  35.  
  36.     def move direction
  37.         case direction
  38.             when "UP"
  39.                 if  @current_room_position [0] > 0
  40.                     @current_room_position [0] -= 1
  41.                 end
  42.             when "DOWN"
  43.                 if  @current_room_position [0] < @map[0].size-1
  44.                     @current_room_position [0] += 1
  45.                 end
  46.             when "LEFT" # unimpemented
  47.             when "RIGHT" #unimplemented
  48.         end
  49.         puts @map[@current_room_position[0]][@current_room_position[1]].description
  50.     end
  51. end
  52. map = Map.new
  53. while input = gets.chomp()
  54.     map.move(input)
  55. end