themable unicode characters
This commit is contained in:
parent
798fb16227
commit
9fc8946428
1 changed files with 15 additions and 6 deletions
|
@ -11,7 +11,14 @@ end
|
||||||
|
|
||||||
require 'myhunt'
|
require 'myhunt'
|
||||||
|
|
||||||
def display_curses( field, state = { dead: false, victory: false } )
|
def display_curses( field,
|
||||||
|
state = { dead: false, victory: false },
|
||||||
|
theme = { explorer: '☺',
|
||||||
|
dead_explorer: '☠',
|
||||||
|
door: '⇒',
|
||||||
|
mine: '◆',
|
||||||
|
cell: '█',
|
||||||
|
visited_cell: ' ' } )
|
||||||
Curses.setpos 0, 0
|
Curses.setpos 0, 0
|
||||||
|
|
||||||
if state[:dead]
|
if state[:dead]
|
||||||
|
@ -26,13 +33,15 @@ def display_curses( field, state = { dead: false, victory: false } )
|
||||||
Curses.setpos y + 2, 0
|
Curses.setpos y + 2, 0
|
||||||
field.width.times do |x|
|
field.width.times do |x|
|
||||||
if [field.explorer_x, field.explorer_y] == [x, y]
|
if [field.explorer_x, field.explorer_y] == [x, y]
|
||||||
Curses.addstr 'O'
|
Curses.addstr state[:dead] ? theme[:dead_explorer] : theme[:explorer]
|
||||||
elsif [field.width, field.height] == [x + 1, y + 1]
|
elsif [field.width, field.height] == [x + 1, y + 1]
|
||||||
Curses.addstr '^'
|
Curses.addstr theme[:door]
|
||||||
elsif field.field[[x, y]].open || state[:dead] || state[:victory]
|
elsif field.field[[x, y]].open
|
||||||
Curses.addstr field.field[[x, y]].mine ? '*' : ' '
|
Curses.addstr theme[:visited_cell]
|
||||||
|
elsif field.field[[x, y]].mine && ( state[:dead] || state[:victory] )
|
||||||
|
Curses.addstr theme[:mine]
|
||||||
else
|
else
|
||||||
Curses.addstr '-'
|
Curses.addstr theme[:cell]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue