-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconsole.html
More file actions
171 lines (167 loc) · 10.7 KB
/
console.html
File metadata and controls
171 lines (167 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-C2YXLNQ21C"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-C2YXLNQ21C');
</script>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>libtcod documentation | Console</title>
<script type="text/javascript" src="../js/doctcod.js"></script>
<link href="../css/style.css" rel="stylesheet" type="text/css">
</head>
<link type="text/css" rel="stylesheet" href="../css/shCore.css">
</link>
<link type="text/css" rel="stylesheet" href="../css/shThemeDefault.css">
</link>
<script language="javascript" src="../js/shCore.js"></script>
<script language="javascript" src="../js/shBrushBash.js"></script>
<body>
<div class="header">
<p><span class="title1">libtcod</span><span class="title2">documentation</span></p>
</div>
<div class="breadcrumb">
<div class="breadcrumbtext">
<p>
you are here: <a onclick="link('../index2.html')">Index</a> > <a onclick="link('console.html')">2.
Console</a><br>
<a class="prev" onclick="link('color.html')">1. Colors</a> | <a class="next" onclick="link('system.html')">3.
System layer</a>
</p>
</div>
</div>
<div class="filter"><input type="checkbox" id="chk_c" name="chk_c" onchange="enable('c',this.checked)"
checked='checked'><label for='chk_c'> C </label><input type="checkbox" id="chk_cpp" name="chk_cpp"
onchange="enable('cpp',this.checked)" checked='checked'><label for='chk_cpp'> C++ </label><input type="checkbox"
id="chk_py" name="chk_py" onchange="enable('py',this.checked)" checked='checked'><label for='chk_py'> Py
</label><input type="checkbox" id="chk_lua" name="chk_lua" onchange="enable('lua',this.checked)"
disabled='disabled'><label class='disabled' for='chk_lua'> Lua </label><input type="checkbox" id="chk_cs"
name="chk_cs" onchange="enable('cs',this.checked)" disabled='disabled'><label class='disabled' for='chk_cs'> C#
</label></div>
<div class="main">
<div class="maintext">
<h1>2. Console</h1>
<div id="toc">
<ul>
<li class="haschildren"><a onclick="link('console_init.html')">2.1. Initializing the console</a>
<ul>
<li><a onclick="link('console_init_root.html')">2.1.1. Creating the game window</a></li>
<li><a onclick="link('console_set_custom_font.html')">2.1.2. Using a custom bitmap font</a></li>
<li><a onclick="link('console_map.html')">2.1.3. Using custom characters mapping</a></li>
<li><a onclick="link('console_fullscreen.html')">2.1.4. Fullscreen mode</a></li>
<li><a onclick="link('console_window.html')">2.1.5. Communicate with the window manager</a></li>
<li><a onclick="link('console_credits.html')">2.1.6. libtcod's credits</a></li>
</ul>
</li>
<li class="haschildren"><a onclick="link('console_draw.html')">2.2. Drawing on the root console</a>
<ul>
<li><a onclick="link('console_draw_basic.html')">2.2.1. Basic printing functions</a></li>
<li><a onclick="link('console_bkgnd_flag_t.html')">2.2.2. Background effect flags</a></li>
<li><a onclick="link('console_print.html')">2.2.3. String drawing functions</a></li>
<li><a onclick="link('console_advanced.html')">2.2.4. Advanced printing functions</a></li>
<li><a onclick="link('console_read.html')">2.2.5. Reading the content of the console</a></li>
<li><a onclick="link('console_fading.html')">2.2.6. Screen fading functions</a></li>
<li><a onclick="link('console_ascii.html')">2.2.7. ASCII constants</a></li>
</ul>
</li>
<li><a onclick="link('console_flush.html')">2.3. Flushing the root console</a></li>
<li class="haschildren"><a onclick="link('console_input.html')">2.4. Handling user input</a>
<ul>
<li><a onclick="link('console_blocking_input.html')">2.4.1. Blocking user input</a></li>
<li><a onclick="link('console_non_blocking_input.html')">2.4.2. Non blocking user input</a></li>
<li><a onclick="link('console_key_t.html')">2.4.3. Keyboard event structure</a></li>
<li><a onclick="link('console_mouse_t.html')">2.4.4. Mouse event structure</a></li>
<li><a onclick="link('console_keycode_t.html')">2.4.5. Key codes</a></li>
</ul>
</li>
<li><a onclick="link('console_offscreen.html')">2.5. Using off-screen consoles</a></li>
</ul>
</div>
<div id="toc">
<ul>
</ul>
</div>
<p>The console emulator handles the rendering of the game screen and the keyboard input.<br />Classic real time
game loop:<br /> </p>
<a name="0"></a>
<div class="code">
<p class="cpp">TCODConsole<span class="code-symbol">::</span>initRoot<span class="code-symbol">(</span><span
class="code-value">80</span><span class="code-symbol">,</span><span class="code-value">50</span><span
class="code-symbol">,</span><span class="code-string">"my game"</span><span
class="code-symbol">,</span><span class="code-keyword">false</span><span class="code-symbol">)</span><span
class="code-symbol">;</span><br />TCODSystem<span class="code-symbol">::</span>setFps<span
class="code-symbol">(</span><span class="code-value">25</span><span class="code-symbol">)</span><span
class="code-symbol">;</span><span class="code-comment"> // limit framerate to 25 frames per
second<br /></span><span class="code-keyword">while</span><span class="code-symbol"> (</span><span
class="code-symbol">!</span>endGame<span class="code-symbol"> &&</span><span class="code-symbol">
!</span>TCODConsole<span class="code-symbol">::</span>isWindowClosed<span class="code-symbol">(</span><span
class="code-symbol">)</span><span class="code-symbol">)</span><span class="code-symbol"> {</span><span
class="code-tcod"><br /> TCOD_key_t</span> key<span
class="code-symbol">;</span><br /> TCODSystem<span
class="code-symbol">::</span>checkForEvent<span class="code-symbol">(</span><span
class="code-tcod">TCOD_EVENT_KEY_PRESS</span><span class="code-symbol">,</span><span
class="code-symbol">&</span>key<span class="code-symbol">,</span><span class="code-tcod">NULL</span><span
class="code-symbol">)</span><span class="code-symbol">;</span><br /> updateWorld<span
class="code-symbol"> (</span>key<span class="code-symbol">,</span> TCODSystem<span
class="code-symbol">::</span>getLastFrameLength<span class="code-symbol">(</span><span
class="code-symbol">)</span><span class="code-symbol">)</span><span class="code-symbol">;</span><span
class="code-comment"><br /> // updateWorld(TCOD_key_t key, float elapsed) (using key
if key.vk != TCODK_NONE)<br /> // use elapsed to scale any update that is time
dependent.<br /> // ... draw world+GUI on
TCODConsole::root<br /> </span>TCODConsole<span
class="code-symbol">::</span>flush<span class="code-symbol">(</span><span class="code-symbol">)</span><span
class="code-symbol">;</span><span class="code-symbol"><br />}</span></p>
</div>
<a name="1"></a>
<p>Classic turn by turn game loop:<br /> </p>
<div class="code">
<p class="cpp">TCODConsole<span class="code-symbol">::</span>initRoot<span class="code-symbol">(</span><span
class="code-value">80</span><span class="code-symbol">,</span><span class="code-value">50</span><span
class="code-symbol">,</span><span class="code-string">"my game"</span><span
class="code-symbol">,</span><span class="code-keyword">false</span><span class="code-symbol">)</span><span
class="code-symbol">;</span><span class="code-keyword"><br />while</span><span class="code-symbol">
(</span><span class="code-symbol">!</span>endGame<span class="code-symbol"> &&</span><span
class="code-symbol"> !</span>TCODConsole<span class="code-symbol">::</span>isWindowClosed<span
class="code-symbol">(</span><span class="code-symbol">)</span><span class="code-symbol">)</span><span
class="code-symbol"> {</span><span class="code-comment"><br /> // ... draw on
TCODConsole::root<br /> </span>TCODConsole<span
class="code-symbol">::</span>flush<span class="code-symbol">(</span><span class="code-symbol">)</span><span
class="code-symbol">;</span><span class="code-tcod"><br /> TCOD_key_t</span> key<span
class="code-symbol">;</span><br /> TCODConsole<span
class="code-symbol">::</span>waitForEvent<span class="code-symbol">(</span><span
class="code-tcod">TCOD_EVENT_KEY_PRESS</span><span class="code-symbol">,</span><span
class="code-symbol">&</span>key<span class="code-symbol">,</span><span class="code-tcod">NULL</span><span
class="code-symbol">,</span><span class="code-keyword">true</span><span class="code-symbol">)</span><span
class="code-symbol">;</span><span class="code-comment"><br /> //... update world,
using key<br /></span><span class="code-symbol">}</span></p>
</div>
</div>
</div>
<div class="footer">
<div class="footertext">
<p>libtcod 1.6.4, © 2008, 2009, 2010, 2012, 2017 Jice, Mingos & rmtew<br>
This file has been generated by doctcod.</p>
<p>
<table width='100%'>
<tr>
<td width="33%"><a href="https://github.com/libtcod/libtcod">libtcod website</a></td>
<td width="33%"><a href="https://www.reddit.com/r/roguelikedev">libtcod on /r/roguelikedev</a></td>
<td width="33%">libtcod tutorials [ <a
href="http://www.roguebasin.com/index.php?title=Complete_Roguelike_Tutorial,_using_python%2Blibtcod">Python</a> | <a
href="http://www.roguebasin.com/index.php?title=Complete_roguelike_tutorial_using_C%2B%2B_and_libtcod_-_part_1:_setting_up">C++</a> ]
</td>
</tr>
</table>
</p>
</div>
</div>
</body>
<script>
initFilter();
SyntaxHighlighter.all();
</script>
</html>