-
Notifications
You must be signed in to change notification settings - Fork 0
/
world_class.rb
30 lines (25 loc) · 938 Bytes
/
world_class.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Responsible for creating worlds.
class World
def initialize(map_array)
@size = 20 #Size is currently static, but can be made dynamic. Use word_builder.rb.
@world_map = map_array
end
attr_accessor :world_map #Allows the world map to be read and edited.
def read_specific_index(y_index,x_index) #Returns a specific value in the map array.
return @world_map[y_index][x_index]
end
def write_specific_index(y_index,x_index,value) #Changes a specific value in the map array.
@world_map[y_index][x_index] = value
end
#Responsible for drawing the map after each move and when the game starts.
def draw_world(char_y_position,char_x_position)
print "\033c" #Clears the screen.
#Draws a subsection of the game_world array based on the row/col variables.
@world_map[(char_y_position-7)..(char_y_position+7)].each{|x|
x[(char_x_position-3)..(char_x_position+3)].each{|num|
print num
}
puts ""
}
end
end