Class: GamesAndRpgParadise::MapGenerator
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::MapGenerator
show all
- Defined in:
- lib/games_and_rpg_paradise/utility_scripts/map_generator/map_generator.rb
Overview
GamesAndRpgParadise::MapGenerator
Constant Summary
collapse
- T =
TABULATOR = '|'
- HORIZONTAL_LINE =
'---'
'+---'
- VERTICAL_BAR =
'|'
- N_TIMES =
90
Instance Method Summary
collapse
Constructor Details
#initialize(run_already = true) ⇒ MapGenerator
45
46
47
48
49
50
|
# File 'lib/games_and_rpg_paradise/utility_scripts/map_generator/map_generator.rb', line 45
def initialize(
run_already = true
)
reset
run if run_already
end
|
Instance Method Details
#reset ⇒ Object
55
56
57
58
|
# File 'lib/games_and_rpg_paradise/utility_scripts/map_generator/map_generator.rb', line 55
def reset
@run_the_height_n_times = 10
end
|
#run ⇒ Object
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
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/games_and_rpg_paradise/utility_scripts/map_generator/map_generator.rb', line 63
def run
x = y = 9
w = 10 v = ['|'] * 100
p = 0
f_array = Array.new(90)
g_array = Array.new(90)
N_TIMES.times {
array = [] while true
array << 1 if p % 9 < 9 && VERTICAL_BAR
array << -w if p >= w && VERTICAL_BAR array << -1 if p % w > 0 && VERTICAL_BAR
array << w if p < y * w && VERTICAL_BAR
if array.empty?
t = '|'
loop {
p += 1
__ = p % 100
_ = (p = __) t = VERTICAL_BAR
break if t == false
}
else
break
end
end
eval( {
1 => 'g_array[p/x+p%w',
-1 => 'g_array[p/w*x+(p-1)%w',
w => 'f_array[p',
-w => 'f_array[p-w'
}[np = array[(array.length * rand).to_i]]+']=T'
)
v[p += np] = nil
}
long_line = (START_HEADER * 10) +'+' e long_line
@run_the_height_n_times.times { |n_time|
e TABULATOR+' '+g_array[n_time * x, x].map { |d|
d ? ' ':'|'
}.join(' ')+' '+TABULATOR
e '+'+f_array[n_time * w, w].map {|d|
d ? ' ': HORIZONTAL_LINE
}.join('+')+'+' if n_time != y
}
e long_line
end
|