Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Room
- attr_accessor :contents, :description
- end
- class Contents
- attr_accessor :contents
- def initialize contents
- @contents = contents
- end
- end
- class Player
- attr_accessor :inventory
- end
- class Map
- def initialize
- airlock1 = Room.new
- airlock1.description = "The airlock of a space station. It contains:"
- airlock1.contents = Contents.new ["Spacesuit", "Clipboard", "Flashlight"]
- science_lab = Room.new
- science_lab.description = "You're in the science lab. It contains:"
- science_lab.contents = Contents.new ["Plasma Cutter", "Chemicals", "USB Drive"]
- mess_hall = Room.new
- mess_hall.description = "You're in the mess hall. It contains:"
- crew_quarters = Room.new
- crew_quarters.description = "You're in the crew quarters. It contains:"
- @map = [[airlock1, science_lab],[mess_hall, crew_quarters]]
- @current_room_position = [0,0]
- end
- def move direction
- case direction
- when "UP"
- if @current_room_position [0] > 0
- @current_room_position [0] -= 1
- end
- when "DOWN"
- if @current_room_position [0] < @map[0].size-1
- @current_room_position [0] += 1
- end
- when "LEFT" # unimpemented
- when "RIGHT" #unimplemented
- end
- puts @map[@current_room_position[0]][@current_room_position[1]].description
- end
- end
- map = Map.new
- while input = gets.chomp()
- map.move(input)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement