Class: TCOD::Console
- Inherits:
-
Object
- Object
- TCOD::Console
- Defined in:
- lib/libtcod/console.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#ptr ⇒ Object
Returns the value of attribute ptr.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #blit(src, xSrc, ySrc, wSrc, hSrc, xDst, yDst, foregroundAlpha = 1.0, backgroundAlpha = 1.0) ⇒ Object
- #check_for_keypress(flags = TCOD::KEY_PRESSED) ⇒ Object
- #clear ⇒ Object
- #flush ⇒ Object
- #init_root(width, height, title, fullscreen = false, renderer = RENDERER_SDL) ⇒ Object
-
#initialize(w, h, root = false) ⇒ Console
constructor
A new instance of Console.
- #is_fullscreen? ⇒ Boolean
- #key_pressed?(keycode) ⇒ Boolean
- #map_ascii_code_to_font(asciiCode, fontCharX, fontCharY) ⇒ Object
- #map_ascii_codes_to_font(asciiCode, nbCodes, fontCharX, fontCharY) ⇒ Object
- #print(x, y, fmt, *args) ⇒ Object
- #print_ex(x, y, bkgnd_flag, alignment, fmt, *args) ⇒ Object
- #print_rect(x, y, w, h, fmt, *args) ⇒ Object
- #print_rect_ex(x, y, w, h, bkgnd_flag, alignment, fmt, *args) ⇒ Object
- #put_char(x, y, c, flag = BKGND_DEFAULT) ⇒ Object
- #put_char_ex(x, y, c, foreground, background) ⇒ Object
- #set_alignment(alignment) ⇒ Object
- #set_background_flag(bkgnd_flag) ⇒ Object
- #set_char_background(x, y, col, flag = TCOD::BKGND_SET) ⇒ Object
- #set_char_foreground(x, y, col) ⇒ Object
- #set_custom_font(fontFile, flags, nb_char_horiz = 0, nb_char_vertic = 0) ⇒ Object
- #set_default_background(color) ⇒ Object
- #set_default_foreground(color) ⇒ Object
- #set_fullscreen(bool) ⇒ Object
- #set_window_title(title) ⇒ Object
- #wait_for_keypress(flush = false) ⇒ Object
- #window_closed? ⇒ Boolean
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
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'lib/libtcod/console.rb', line 3 def height @height end |
#ptr ⇒ Object
Returns the value of attribute ptr.
3 4 5 |
# File 'lib/libtcod/console.rb', line 3 def ptr @ptr end |
#width ⇒ Object
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 |
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 |
#clear ⇒ Object
44 |
# File 'lib/libtcod/console.rb', line 44 def clear; TCOD.console_clear(@ptr); end |
#flush ⇒ Object
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
29 |
# File 'lib/libtcod/console.rb', line 29 def is_fullscreen?; TCOD.console_is_fullscreen; end |
#key_pressed?(keycode) ⇒ 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 |
#print(x, y, fmt, *args) ⇒ Object
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 |
#print_ex(x, y, bkgnd_flag, alignment, fmt, *args) ⇒ Object
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 |
#print_rect(x, y, w, h, fmt, *args) ⇒ Object
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 |
#print_rect_ex(x, y, w, h, bkgnd_flag, alignment, fmt, *args) ⇒ Object
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
30 |
# File 'lib/libtcod/console.rb', line 30 def window_closed?; TCOD.console_is_window_closed; end |