Class: Curses::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/game.rb

Instance Method Summary collapse

Instance Method Details

#clear_area(y, x, width, height) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/game.rb', line 29

def clear_area(y, x, width, height)
  blank = " " * width
  height.times do |row|
    setpos(y + row, x)
    addstr(blank)
  end
end

#draw_box(y, x, width, height, art = Box::NORMAL) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/game.rb', line 14

def draw_box(y, x, width, height, art = Box::NORMAL)
  setpos(y, x)
  addstr(art.top.left + art.h * (width - 2) + art.top.right)

  (1...height - 1).each do |row|
    setpos(y + row, x)
    addstr(art.v)
    setpos(y + row, x + width - 1)
    addstr(art.v)
  end

  setpos(y + height - 1, x)
  addstr(art.bottom.left + art.h * (width - 2) + art.bottom.right)
end


2
3
4
5
6
7
8
9
10
11
12
# File 'lib/game.rb', line 2

def print(s, point = nil, color = nil)
  setpos(point.y, point.x) if point

  if color
    attron(Curses.color_pair(color))
    addstr(s)
    attroff(Curses.color_pair(color))
  else
    addstr(s)
  end
end