Last active
April 17, 2020 07:43
-
-
Save iGhost/aab2f839f85cad9462ea81d251ec1e4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WIDTH = 80 | |
HEIGHT = 25 | |
def show_map(map) | |
map.each do |row| | |
row.each do |cell| | |
print cell | |
end | |
puts '' | |
end | |
end | |
def fill_map(map) | |
map.each_with_index do |row, i| | |
row.each_with_index do |f, j| | |
roll = rand(100) | |
if roll > 65 | |
cell = '▩' # Wall | |
elsif roll < 2 | |
cell = '!' # Quest | |
elsif roll < 7 | |
cell = '@' # Enemy | |
else | |
cell = ' ' | |
end | |
map[i][j] = cell #"#{cell}" | |
end | |
end | |
map[0][0] = '%' | |
map[HEIGHT-1][WIDTH-1] = '*' | |
end | |
map = Array.new(HEIGHT) { Array.new(WIDTH) { '.' } } | |
fill_map(map) | |
show_map(map) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment