Crystal Entity Layer: 4.2 Tutorial

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 4.2 Tutorial

This is a tutorial to show how you can use Crystal Entity Layer in your own applications. The game data needed by this tutorial can be downloaded from:

http://www.crystalspace3d.org/celtutorial.zip

Here are the five source files of this tutorial:

### The XML Entity File

Except for the level and player entities all other entities are defined in the ``entities'` file. Here is an example of how such an entity looks:

        <addon plugin="celentity" entityname="badone">

          <propclass name="pcmesh">
            <action name="LoadMeshPath">
    	  <par name="path" string="/this/model" />
    	  <par name="filename" string="monkey" />
    	  <par name="factoryname" string="monkey" />
    	</action>
          </propclass>

          <propclass name="pcmeshselect" />

          <propclass name="pcproperties">
            <property name="pos1" vector="9,2,8" />
            <property name="pos2" vector="6,2,8" />
            <property name="pos3" vector="6,2,12" />
            <property name="pos4" vector="7,5,10" />
            <property name="pos5" vector="8,1,7" />
            <property name="pos6" vector="9,2,8" />
            <property name="up1" vector="0,1,0" />
            <property name="up2" vector="0,1,0" />
            <property name="up3" vector="0,1,0" />
            <property name="up4" vector="0,1,0" />
            <property name="up5" vector="0,1,0" />
            <property name="up6" vector="0,1,0" />
            <property name="forward1" vector="-1,0,0" />
            <property name="forward2" vector="0,0,1" />
            <property name="forward3" vector="1,1,-1" />
            <property name="forward4" vector="1,-1,-1" />
            <property name="forward5" vector="1,1,1" />
            <property name="forward6" vector="-1,0,0" />
            <property name="time1" long="1000" />
            <property name="time2" long="1000" />
            <property name="time3" long="1000" />
            <property name="time4" long="1000" />
            <property name="time5" long="1000" />
            <property name="time6" long="1000" />
          </propclass>

          <propclass name="pctimer">
            <action name="WakeUp">
    	  <par name="time" long="5000" />
    	  <par name="repeat" bool="true" />
    	</action>
          </propclass>

          <propclass name="pclinearmovement">
            <action name="InitCD">
    	  <par name="body" vector=".2,.2,.2" />
    	  <par name="legs" vector=".2,.2,.2" />
    	  <par name="offset" vector="0,-.3,0" />
    	</action>
            <action name="SetPosition">
    	  <par name="position" vector="9,3,8" />
    	  <par name="sector" string="Scene" />
    	  <par name="yrot" float="0" />
    	</action>
          </propclass>

          <behaviour name="badone_behave" />

        </addon>

In this particular example we use the ``cel.addons.celentity'` addon (see section CelEntity Addon) to create an entity with the name ``badone'`. It has the following property classes:

- ``pcmesh'` (see section Mesh). This mesh is setup with the ``monkey'` model that was made in ``Blender'`.
- ``pcmeshselect'` Used for selection of mesh.
- ``pcproperties'` This is a generic property class for storing named properties. In this particular case the ``badone_behave'` behaviour will read out the properties to construct the path for the catmull rom spline.
- ``pctimer'` (see section Timer). This timer will be used to restart the movement along the path after 5 seconds (5000 milliseconds).
- ``pclinearmovement'` (see section Linear Movement). This is the generic movement system.

We also create the entity with the ``badone_behave'` behaviour.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.