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_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 |
# 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
#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
.root ⇒ Object
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
75 76 77 |
# File 'lib/libtcod/console.rb', line 75 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
71 |
# File 'lib/libtcod/console.rb', line 71 def check_for_keypress(flags=TCOD::KEY_PRESSED); TCOD.console_check_for_keypress(flags); end |
#clear ⇒ Object
42 |
# File 'lib/libtcod/console.rb', line 42 def clear; TCOD.console_clear(@ptr); end |
#flush ⇒ Object
69 |
# File 'lib/libtcod/console.rb', line 69 def flush; TCOD.console_flush; end |
#init_root(width, height, title, fullscreen = false, renderer = RENDERER_SDL) ⇒ Object
19 20 21 22 23 |
# File 'lib/libtcod/console.rb', line 19 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
27 |
# File 'lib/libtcod/console.rb', line 27 def is_fullscreen?; TCOD.console_is_fullscreen; end |
#key_pressed?(keycode) ⇒ Boolean
73 |
# File 'lib/libtcod/console.rb', line 73 def key_pressed?(keycode); TCOD.console_is_key_pressed(keycode); end |
#map_ascii_code_to_font(asciiCode, fontCharX, fontCharY) ⇒ Object
32 33 34 |
# File 'lib/libtcod/console.rb', line 32 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
35 36 37 |
# File 'lib/libtcod/console.rb', line 35 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
56 57 58 |
# File 'lib/libtcod/console.rb', line 56 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
59 60 61 |
# File 'lib/libtcod/console.rb', line 59 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
62 63 64 |
# File 'lib/libtcod/console.rb', line 62 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
65 66 67 |
# File 'lib/libtcod/console.rb', line 65 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
44 45 46 |
# File 'lib/libtcod/console.rb', line 44 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
47 48 49 |
# File 'lib/libtcod/console.rb', line 47 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
53 54 55 |
# File 'lib/libtcod/console.rb', line 53 def set_alignment(alignment) TCOD.console_set_alignment(@ptr, alignment) end |
#set_background_flag(bkgnd_flag) ⇒ Object
50 51 52 |
# File 'lib/libtcod/console.rb', line 50 def set_background_flag(bkgnd_flag) TCOD.console_set_background_flag(@ptr, bkgnd_flag) end |
#set_custom_font(fontFile, flags, nb_char_horiz = 0, nb_char_vertic = 0) ⇒ Object
29 30 31 |
# File 'lib/libtcod/console.rb', line 29 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
40 |
# File 'lib/libtcod/console.rb', line 40 def set_default_background(color); TCOD.console_set_default_background(@ptr, color); end |
#set_default_foreground(color) ⇒ Object
41 |
# File 'lib/libtcod/console.rb', line 41 def set_default_foreground(color); TCOD.console_set_default_foreground(@ptr, color); end |
#set_fullscreen(bool) ⇒ Object
26 |
# File 'lib/libtcod/console.rb', line 26 def set_fullscreen(bool); TCOD.console_set_fullscreen(bool); end |
#set_window_title(title) ⇒ Object
25 |
# File 'lib/libtcod/console.rb', line 25 def set_window_title(title); TCOD.console_set_window_title(title); end |
#wait_for_keypress(flush = false) ⇒ Object
72 |
# File 'lib/libtcod/console.rb', line 72 def wait_for_keypress(flush=false); TCOD.console_wait_for_keypress(flush); end |
#window_closed? ⇒ Boolean
28 |
# File 'lib/libtcod/console.rb', line 28 def window_closed?; TCOD.console_is_window_closed; end |