Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 4183

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Crystal Space 1.2.1: 4.16.1 Loading a Level</title>

<meta name="description" content="Crystal Space 1.2.1: 4.16.1 Loading a Level">
<meta name="keywords" content="Crystal Space 1.2.1: 4.16.1 Loading a Level">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="HOWTO-Level-Loading"></a>
<a name="0"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="Map-Loader.html#0" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="XML-File-Format.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Using-Crystal-Space.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="Map-Loader.html#0" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<hr size="1">
<h3 class="subsection"> 4.16.1 Loading a Level </h3>

<p>This section describes how you can load a level in your game.
</p>
<a name="1"></a>
<h4 class="subsubheading"> Getting the Level Loader Plugin </h4>

<p>To load a level you need the level loader plugin. There are two
ways to make sure you have this plugin in your application. You can put
a line in your config file like this:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">System.Plugins.iLoader = crystalspace.level.loader
</pre></td></tr></table>
<p>Or you can add the following line to the call to
<code>csInitializer::RequestPlugins()</code> in your <code>main()</code> function:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">CS_REQUEST_LEVELLOADER,
</pre></td></tr></table>
<p>To finally be able to use the level loader in your application you
need to do:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">csRef&lt;iLoader&gt; level_loader = csQueryRegistry&lt;iLoader&gt; (object_reg);
</pre></td></tr></table>
<p>When you don't need it anymore you must call <code>level_loader-&gt;DecRef ()</code>.
</p>
<a name="2"></a>
<h4 class="subsubheading"> Loading a Map </h4>

<p>Loading a map is simple. You just do:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">VFS-&gt;ChDir (&quot;/lev/mymap&quot;);
level_loader-&gt;LoadMapFile (&quot;world&quot;);
engine-&gt;Prepare ();
</pre></td></tr></table>
<p>This will first set the current directory to the right <small>VFS</small> dir
(see section <a href="VFS.html#0">Virtual File System (<small>VFS</small>)</a>) and then it will load the map file which is called 'world' (this
is not a requirement).
</p>
<p>Note that this will clear all other geometry that might have been
loaded in the engine before. If you don't want that then you need to
set the second parameter of <code>LoadMapFile</code> to <code>false</code>.
</p>
<p>The line <code>engine-&gt;Prepare()</code> will make sure that everything that
is loaded is correctly set up (i.e. materials and texture will be registered,
lightmaps will be loaded from the cache, ...).
</p>
<a name="3"></a>
<h4 class="subsubheading"> Include Files </h4>

<p>The include files useful for this section are:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">#include &lt;isys/vfs.h&gt;
#include &lt;imap/loader.h&gt;
#include &lt;iengine/engine.h&gt;
</pre></td></tr></table>
<hr size="1">
<p>
 <font size="-1">
  This document was generated using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

</p>
</body>
</html>