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
18
19
# File 'lib/libtcod/console.rb', line 9

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

  ObjectSpace.define_finalizer(self, self.class.finalize(ptr))
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

#ptrObject

Returns the value of attribute ptr


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

def ptr
  @ptr
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

.finalize(ptr) ⇒ Object


89
90
91
# File 'lib/libtcod/console.rb', line 89

def self.finalize(ptr)
  proc { TCOD.console_delete(ptr) }
end

.rootObject


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

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

Instance Method Details

#blit(src, xSrc, ySrc, wSrc, hSrc, xDst, yDst, foregroundAlpha = 1.0, backgroundAlpha = 1.0) ⇒ Object


85
86
87
# File 'lib/libtcod/console.rb', line 85

def blit(src, xSrc, ySrc, wSrc, hSrc, xDst, yDst, foregroundAlpha=1.0, backgroundAlpha=1.0)
  TCOD.console_blit(src.ptr, xSrc, ySrc, wSrc, hSrc, @ptr, xDst, yDst, foregroundAlpha, backgroundAlpha)
end

#check_for_keypress(flags = TCOD::KEY_PRESSED) ⇒ Object


81
# File 'lib/libtcod/console.rb', line 81

def check_for_keypress(flags=TCOD::KEY_PRESSED); TCOD.console_check_for_keypress(flags); end

#clearObject


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

def clear; TCOD.console_clear(@ptr); end

#flushObject


79
# File 'lib/libtcod/console.rb', line 79

def flush; TCOD.console_flush; end

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


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

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

#is_fullscreen?Boolean

Returns:

  • (Boolean)

29
# File 'lib/libtcod/console.rb', line 29

def is_fullscreen?; TCOD.console_is_fullscreen; end

#key_pressed?(keycode) ⇒ Boolean

Returns:

  • (Boolean)

83
# File 'lib/libtcod/console.rb', line 83

def key_pressed?(keycode); TCOD.console_is_key_pressed(keycode); end

#map_ascii_code_to_font(asciiCode, fontCharX, fontCharY) ⇒ Object


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

def map_ascii_code_to_font(asciiCode, fontCharX, fontCharY)
  TCOD.console_map_ascii_code_to_font(asciiCode.ord, fontCharX, fontCharY)
end

#map_ascii_codes_to_font(asciiCode, nbCodes, fontCharX, fontCharY) ⇒ Object


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

def map_ascii_codes_to_font(asciiCode, nbCodes, fontCharX, fontCharY)
  TCOD.console_map_ascii_code_to_font(asciiCode.ord, nbCodes, fontCharX, fontCharY)
end

66
67
68
# File 'lib/libtcod/console.rb', line 66

def print(x, y, fmt, *args)
  TCOD.console_print(@ptr, x, y, fmt, *args)
end

69
70
71
# File 'lib/libtcod/console.rb', line 69

def print_ex(x, y, bkgnd_flag, alignment, fmt, *args)
  TCOD.console_print_ex(@ptr, x, y, bkgnd_flag, alignment, fmt, *args)
end

72
73
74
# File 'lib/libtcod/console.rb', line 72

def print_rect(x, y, w, h, fmt, *args)
  TCOD.console_print_rect(@ptr, x, y, w, h, fmt, *args)
end

75
76
77
# File 'lib/libtcod/console.rb', line 75

def print_rect_ex(x, y, w, h, bkgnd_flag, alignment, fmt, *args)
  TCOD.console_print_rect_ex(@ptr, x, y, w, h, bkgnf_flag, alignment, fmt, *args)
end

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


54
55
56
# File 'lib/libtcod/console.rb', line 54

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

#put_char_ex(x, y, c, foreground, background) ⇒ Object


57
58
59
# File 'lib/libtcod/console.rb', line 57

def put_char_ex(x, y, c, foreground, background)
  TCOD.console_put_char_ex(@ptr, x, y, c.ord, foreground, background)
end

#set_alignment(alignment) ⇒ Object


63
64
65
# File 'lib/libtcod/console.rb', line 63

def set_alignment(alignment)
  TCOD.console_set_alignment(@ptr, alignment)
end

#set_background_flag(bkgnd_flag) ⇒ Object


60
61
62
# File 'lib/libtcod/console.rb', line 60

def set_background_flag(bkgnd_flag)
  TCOD.console_set_background_flag(@ptr, bkgnd_flag)
end

#set_char_background(x, y, col, flag = TCOD::BKGND_SET) ⇒ Object


46
47
48
# File 'lib/libtcod/console.rb', line 46

def set_char_background(x, y, col, flag=TCOD::BKGND_SET)
  TCOD.console_set_char_background(@ptr, x, y, col, flag)
end

#set_char_foreground(x, y, col) ⇒ Object


50
51
52
# File 'lib/libtcod/console.rb', line 50

def set_char_foreground(x, y, col)
  TCOD.console_set_char_foreground(@ptr, x, y, col)
end

#set_custom_font(fontFile, flags, nb_char_horiz = 0, nb_char_vertic = 0) ⇒ Object


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

def set_custom_font(fontFile, flags, nb_char_horiz=0, nb_char_vertic=0)
  TCOD.console_set_custom_font(fontFile, flags, nb_char_horiz, nb_char_vertic)
end

#set_default_background(color) ⇒ Object


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

def set_default_background(color); TCOD.console_set_default_background(@ptr, color); end

#set_default_foreground(color) ⇒ Object


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

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

#set_fullscreen(bool) ⇒ Object


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

def set_fullscreen(bool); TCOD.console_set_fullscreen(bool); end

#set_window_title(title) ⇒ Object


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

def set_window_title(title); TCOD.console_set_window_title(title); end

#wait_for_keypress(flush = false) ⇒ Object


82
# File 'lib/libtcod/console.rb', line 82

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

#window_closed?Boolean

Returns:

  • (Boolean)

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

def window_closed?; TCOD.console_is_window_closed; end