Source

libtcod / doc / html2 / heightmap_init.html

Full commit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>libtcod documentation | Creating a heightmap</title>
<script type="text/javascript" src="../js/doctcod.js"></script>
<link href="../css/style.css" rel="stylesheet" type="text/css"></head>
<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> &gt; <a onclick="link('heightmap.html')">14. Heightmap toolkit</a> &gt; <a onclick="link('heightmap_init.html')">14.1. Creating a heightmap</a><br>
 <a class="next" onclick="link('heightmap_base.html')">14.2. Basic operations</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_cs" name="chk_cs" onchange="enable('cs',this.checked)" checked='checked' ><label  for='chk_cs'> 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)" checked='checked' ><label  for='chk_lua'> Lua   </label></div>
<div class="main"><div class="maintext">
<h1>14.1. Creating a heightmap</h1>
<div id="toc"><ul>
<li><a href="#0">Creating an empty map</a></li><li><a href="#1">Destroying a heightmap</a></li></ul></div>
<a name="0"></a><h3>Creating an empty map</h3>
<p>As with other modules, you have to create a heightmap object first :<br />		Note that whereas most other modules use opaque structs, the TCOD_heightmap_t fields can be freely accessed. Thus, the TCOD_heightmap_new function returns a TCOD_heightmap_t pointer, not a TCOD_heightmap_t. The w and h fields should not be modified after the heightmap creation. The newly created heightmap is filled with 0.0 values.<br />	</p>
<div class="code"><p class="cpp">TCODHeightMap<span class="code-symbol">::</span>TCODHeightMap<span class="code-symbol">(</span><span class="code-keyword">int</span> w<span class="code-symbol">,</span><span class="code-keyword"> int</span> h<span class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">typedef</span><span class="code-keyword"> struct</span><span class="code-symbol"> {</span><span class="code-keyword"><br />&nbsp;&nbsp;&nbsp;&nbsp;int</span> w<span class="code-symbol">,</span>h<span class="code-symbol">;</span><span class="code-keyword"><br />&nbsp;&nbsp;&nbsp;&nbsp;float</span><span class="code-symbol"> *</span>values<span class="code-symbol">;</span><span class="code-symbol"><br />}</span><span class="code-tcod"> TCOD_heightmap_t</span><span class="code-symbol">;</span><span class="code-tcod"><br />TCOD_heightmap_t</span><span class="code-symbol"> *</span>TCOD_heightmap_new<span class="code-symbol">(</span><span class="code-keyword">int</span> w<span class="code-symbol">,</span><span class="code-keyword">int</span> h<span class="code-symbol">)</span></p>
<p class="py">heightmap_new<span class="code-symbol">(</span>w<span class="code-symbol">,</span>h<span class="code-symbol">)</span></p>
<p class="cs">TCODHeightMap<span class="code-symbol">:</span><span class="code-symbol">:</span>TCODHeightMap<span class="code-symbol">(</span><span class="code-keyword">int</span> w<span class="code-symbol">,</span><span class="code-keyword"> int</span> h<span class="code-symbol">)</span></p>
</div>
<table class="param"><tbody><tr><th>Parameter</th><th>Description</th></tr><tr class="hilite"><td>w,h</td><td>The width and height of the heightmap.<br />	</td></tr>
</tbody></table><h6>Example:</h6><div class="code">
<p class="cpp">TCODHeightMap myMap<span class="code-symbol">(</span><span class="code-value">50</span><span class="code-symbol">,</span><span class="code-value">50</span><span class="code-symbol">)</span><span class="code-symbol">;</span></p>
<p class="c"><span class="code-tcod">TCOD_heightmap_t</span><span class="code-symbol"> *</span>my_map<span class="code-symbol">=</span>TCOD_heightmap_new<span class="code-symbol">(</span><span class="code-value">50</span><span class="code-symbol">,</span><span class="code-value">50</span><span class="code-symbol">)</span><span class="code-symbol">;</span></p>
<p class="py">map<span class="code-symbol">=</span>libtcod<span class="code-symbol">.</span>heightmap_new<span class="code-symbol">(</span><span class="code-value">50</span><span class="code-symbol">,</span><span class="code-value">50</span><span class="code-symbol">)</span><span class="code-keyword"><br />print</span> map<span class="code-symbol">.</span>w<span class="code-symbol">,</span> map<span class="code-symbol">.</span>h</p>
</div><hr>
<a name="1"></a><h3>Destroying a heightmap</h3>
<p>To release the resources used by a heightmap, destroy it with :<br />	</p>
<div class="code"><p class="cpp">TCODHeightMap<span class="code-symbol">::</span><span class="code-symbol">~</span>TCODHeightMap<span class="code-symbol">(</span><span class="code-symbol">)</span></p>
<p class="c"><span class="code-keyword">void</span> TCOD_heightmap_delete<span class="code-symbol">(</span><span class="code-tcod">TCOD_heightmap_t</span><span class="code-symbol"> *</span>hm<span class="code-symbol">)</span></p>
<p class="py">heightmap_delete<span class="code-symbol">(</span>hm<span class="code-symbol">)</span></p>
<p class="cs"><span class="code-keyword">void</span> TCODHeightMap<span class="code-symbol">:</span><span class="code-symbol">:</span>Dispose<span class="code-symbol">(</span><span class="code-symbol">)</span></p>
</div>
<table class="param"><tbody><tr><th>Parameter</th><th>Description</th></tr><tr class="hilite"><td>hm</td><td>In the C version, the address of the heightmap struct returned by the creation function.<br />	</td></tr>
</tbody></table>
</div></div>
<div class="footer"><div class="footertext">
	<p>libtcod 1.5.1, &copy; 2008, 2009, 2010, 2012 Jice & Mingos<br>
	This file has been generated by doctcod.</p>
	<p><table width='100%'><tr><td><a href="http://doryen.eptalys.net/libtcod">libtcod website</a></td>
	<td><a href="http://doryen.eptalys.net/forum/index.php?board=12.0">libtcod on Roguecentral forums</a></td>
  <td><a href="http://www.youtube.com/watch?v=PY9lJnVQbXs&feature=PlayList&p=553E3D00A1460331&playnext_from=PL&index=0&playnext=1">libtcod HOWTO video tutorials</a></td></tr></table></p>
</div></div>
</body>
<script>
initFilter();
</script>
</html>