Class: MISSIONGAME::NewOrleans
- Inherits:
-
Object
- Object
- MISSIONGAME::NewOrleans
- Defined in:
- lib/neworleans.rb
Instance Attribute Summary collapse
-
#the_map ⇒ Object
readonly
Returns the value of attribute the_map.
Instance Method Summary collapse
-
#check_area(args) ⇒ Object
Check the current area on the map and describe it.
- #get_height ⇒ Object
-
#get_map(args) ⇒ Object
Return map data in a display format.
- #get_width ⇒ Object
-
#initialize ⇒ NewOrleans
constructor
A new instance of NewOrleans.
Constructor Details
#initialize ⇒ NewOrleans
Returns a new instance of NewOrleans.
43 44 45 46 |
# File 'lib/neworleans.rb', line 43 def initialize # Set initial New Orleans map generate_map end |
Instance Attribute Details
#the_map ⇒ Object (readonly)
Returns the value of attribute the_map.
41 42 43 |
# File 'lib/neworleans.rb', line 41 def the_map @the_map end |
Instance Method Details
#check_area(args) ⇒ Object
Check the current area on the map and describe it
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/neworleans.rb', line 102 def check_area(args) player = args[:player] ui = args[:ui] story = args[:story] x = player.x y = player.y current_area = @the_map[y-1][x-1] case current_area when MAP_KEY_TREE ui.draw_frame({:text => story.area_tree}) when MAP_KEY_WATER ui.draw_frame({:text => story.area_water}) when MAP_KEY_MOUNTAIN ui.draw_frame({:text => story.area_mountain}) when MAP_KEY_ENEMY ui.draw_frame({:text => story.area_enemy}) return false end return true end |
#get_height ⇒ Object
52 53 54 |
# File 'lib/neworleans.rb', line 52 def get_height MAP_HEIGHT end |
#get_map(args) ⇒ Object
Return map data in a display format
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/neworleans.rb', line 57 def get_map(args) player = args[:player] buffer = Array.new x = 1 y = 1 @the_map.each do |row| tmp_row = Array.new x = 1 row.each do |col| placed = 0 # Place WITCH if x == MAP_WITCH_X and y == MAP_WITCH_Y tmp_row << MAP_KEY_WITCH.colorize(:color => :white, :background => :red) placed = 1 end # If player is here, display them if x == player.x and y == player.y tmp_row << MAP_KEY_PLAYER.colorize(:color => :red, :background => :white) placed = 1 end # If we haven't already placed the Player, run through the rest of the options if placed == 0 case col when MAP_KEY_TREE tmp_row << col.colorize(:color => :light_green, :background => :green) when MAP_KEY_GRASS tmp_row << col.colorize(:color => :green, :background => :green) when MAP_KEY_WATER tmp_row << col.colorize(:color => :white, :background => :blue) when MAP_KEY_MOUNTAIN tmp_row << col.colorize(:color => :yellow, :background => :green) when MAP_KEY_ENEMY tmp_row << col.colorize(:color => :red, :background => :green) end end x += 1 end buffer << tmp_row y += 1 end return buffer end |
#get_width ⇒ Object
48 49 50 |
# File 'lib/neworleans.rb', line 48 def get_width MAP_WIDTH end |