Class: TCOD::Console

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(w, h, root = False) ⇒ Console

Returns a new instance of Console.



9
10
11
12
13
14
15
16
17
# File 'lib/libtcod/console.rb', line 9

def initialize(w, h, root=False)
  if root
    @ptr = nil
  else
    @width = w
    @height = w
    @ptr = TCOD.console_new(w, h)
  end
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/libtcod/console.rb', line 3

def height
  @height
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/libtcod/console.rb', line 3

def width
  @width
end

Class Method Details

.init_root(width, height, title, fullscreen = false, renderer = RENDERER_SDL) ⇒ Object



19
20
21
22
23
24
# File 'lib/libtcod/console.rb', line 19

def self.init_root(width, height, title, fullscreen=false, renderer=RENDERER_SDL)
  TCOD.console_init_root(width, height, title, fullscreen, renderer)
  root.width = width
  root.height = height
  root
end

.rootObject



5
6
7
# File 'lib/libtcod/console.rb', line 5

def self.root
  @root ||= TCOD.nsole.new(0, 0, true)
end

Instance Method Details

#flushObject



38
39
40
# File 'lib/libtcod/console.rb', line 38

def flush
  TCOD.console_flush
end

#put_char(x, y, c, flag = BKGND_DEFAULT) ⇒ Object



34
35
36
# File 'lib/libtcod/console.rb', line 34

def put_char(x, y, c, flag=BKGND_DEFAULT)
  TCOD.console_put_char(@ptr, x, y, c.ord, flag)
end

#set_default_foreground(color) ⇒ Object



30
31
32
# File 'lib/libtcod/console.rb', line 30

def set_default_foreground(color)
  TCOD.console_set_default_foreground(@ptr, color)
end

#wait_for_keypress(flush = false) ⇒ Object



42
43
44
# File 'lib/libtcod/console.rb', line 42

def wait_for_keypress(flush=false)
  TCOD.console_wait_for_keypress(flush)
end

#window_closed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/libtcod/console.rb', line 26

def window_closed?
  TCOD.console_is_window_closed
end