data['title']); if($title_nice != "Main Page") { echo "

"; echo $title_nice; echo "

"; } ?>

Deutsch - Català - Español

If you use a property requiring xmoto >= 0.2.1 for example, you must modify the level tag like this :

<level id="myid" rversion="0.2.1">

Contents

Level properties

<info>
<name>Level name</name>
<description></description>
<author></author>
<date></date>
<sky zoom="0.1" offset="0.1" 
color_r="255" color_g="255" color_b="255" color_a="0"
drifted="true" driftZoom="1.0"
driftColor_r="255" driftColor_g="255" driftColor_b="0" driftColor_a="0">Space</sky>
<border texture="Bricks" />
<music name="batcave" />
</info>
<theme_replacements>
<sprite_replacement old_name="Strawberry" new_name="Star" />
<sprite_replacement old_name="Wrecker" new_name="Star" />
<sprite_replacement old_name="Flower" new_name="Strawberry" />
<sprite_replacement old_name="Star" new_name="Wrecker" />
<sound_replacement  old_name="PickUpStrawberry" new_name="Squeek" />
</theme_replacements>
<layeroffsets>
<layeroffset x="0.2" y="1.0"/>
<layeroffset x="0.3" y="1.0"/>
<layeroffset x="0.5" y="1.0"/>
<layeroffset x="1.9" y="1.0" frontlayer="true"/>
<layeroffset x="2.5" y="1.0" frontlayer="true"/>
</layeroffsets>
  • sky : several properties to change the sky texture (some color effects, ...) [require xmoto >= 0.2.5]
    • zoom : size of the texture
    • offset : offset with the sky when moving the bike
    • color_r color_g color_b color_a : red, green, blue and alpha color apply to the texture
    • drifted : set the drifted effect activated
    • driftZoom : size of the drift texture
    • driftColor_r, driftColor_g, driftColor_b, driftColor_a : color apply to the drift texture
  • border : border of the level [require xmoto >= 0.2.5]
  • music : music played while playing the level (with 0.2.5, batcave, menu1 and rideALong are available) [require xmoto >= 0.2.5]
  • theme_replacements : you can replace a special sprite like Flower by an other picture and a sound by another one (you can replace Wrecker, Strawberry, Star, Flower and PickUpStrawberry) [require xmoto >= 0.2.5]
  • parallax layers: allow you to have different background and front parallax layers of blocks. In the example, there's three background layers (0, 1 and 2) and two front layers (3 and 4). [require xmoto >= 0.2.5]
  • Now, there's two layers of static blocks. If you add 'islayer="true"' in the position of a block, then the block will be in the second static block layer which is display on top of the existing static block layer.

Example

<sky color_r="150" color_g="100" color_b="50" zoom="3.0">sky1</sky>

Image:SkyAtmosphere.jpg

Layers

To see parallax layers at work, check out the Green Hill Zone Act 1&2 levels.

Parallax layers

Since 0.2.6 you can add background and front parallax layers of blocks (non dynamic blocks which can't interact with the biker, only for visual effects) with no limit in the number of layers.

For each layer, you can put three different properties:

  • X scroll: the scrolling on the X axis.
  • Y scroll: the scrolling on the Y axis.
  • is front: the layer is a front layer.

The X and Y scrolls are float, here are the possible values:

  • scroll = 0 : the layer won't scroll
  • 0 < scroll < 1 : the layer will scroll slower than the level
  • scroll = 1.0 : the layer will scroll at the same speed than the level
  • scroll > 1.0 : the layer will scroll faster than the level

In this example, there's five layers in the level, three background layers and two front layers. background layers are layers 0, 1 and 2, front layers are layers 3 and 4 (first layer is the layer 0). Layers scroll at the same speed than the level on the Y axis. The three background layers scroll slower than the level and the two front layers scroll faster than the level.

<layeroffsets>
 <layeroffset x="0.2" y="1.0"/>
 <layeroffset x="0.3" y="1.0"/>
 <layeroffset x="0.5" y="1.0"/>
 <layeroffset x="1.9" y="1.0" frontlayer="true"/>
 <layeroffset x="2.5" y="1.0" frontlayer="true"/>
</layeroffsets>

The layer information has to be put in the level header, for example after the <info></info> block of datas.

Layers are rendered in the order of their appearance in the xml file, so in this example, here is the order of rendering:

  1. the background layer 0, with its x offset of 0.2
  2. the background layer 1, with its x offset of 0.3
  3. the background layer 2, with its x offset of 0.5
  4. the actual level
  5. the front layer 3, with its x offset of 1,9
  6. the front layer 4, with its x offset of 2.5

Here is how to update the blocks to put them in a layer:

Blockxxx in the first background layer (layerid: 0):

<position x="-17.175000" y="14.525000" islayer="true" layerid="0"/> 

Blockyyy in the first front layer (layerid: 3):

<position x="-17.175000" y="14.525000" islayer="true" layerid="3"/>

Real example

Here is the beginning of the xml file for the level Green Hill Zone Act 2:

<level id="sonichedgehog2" rversion="0.2.6">
       <info>
               <name>Green Hill Zone Act 2</name>
               <description>The return of the hedgehog. Made with Inkscape.</description>
               <author>The Only Dude (Textures, Sprites and Music by Gaivota)</author>
               <date>2007-02-19</date>
               <sky>sky1</sky>
               <border texture="chessy_dark"/>
               <music name="rideALong" />
       </info>
       <theme_replacements>
               <sprite_replacement old_name="Strawberry" new_name="ring" />
               <sprite_replacement old_name="Wrecker" new_name="evilfish" />
               <sprite_replacement old_name="Flower" new_name="panel" />
               <sound_replacement  old_name="PickUpStrawberry" new_name="ring" />
       </theme_replacements>
       <layeroffsets>
               <layeroffset x="0.1" y="0.02" name="mountains"/>
               <layeroffset x="0.2" y="0.02" name="clouds"/>
               <layeroffset x="0.3" y="0.02" name="hills"/>
               <layeroffset x="0.6" y="0.02" name="water"/>
               <layeroffset x="0.8" y="0.02" name="front water"/>
       </layeroffsets>
       <limits left="-80" right="80" top="65" bottom="-65"/>

Note that there's a parameter called 'name' in the layeroffset tag, this parameter is not used by xmoto, I just add it to easily remember what each layer contains.

Here is the beginning of some blocks which are in layers:

       <block id="path4868">
               <position islayer="true" x="-80.237500" y="65.378908" layerid="3"/>
               <usetexture id="Water1"/>
               <vertex x="84.846875" y="-13.496875"/>
       <block id="path15977">
               <position islayer="true" x="-80.237500" y="65.378908" layerid="4"/>
               <usetexture id="Water2"/>
               <vertex x="145.810941" y="-13.876563"/>

Static blocks

Since xmoto 0.2.6, the rendering order of blocks have changed. Before 0.2.6, blocks were rendered in the same order as the order of blocks in the xml level file. Now, visible blocks are sorted on their texture before being rendered.

As a consequence, some static blocks can be rendered behind some others, so now there's two layers of static blocks (there's a new layer of static blocks in front of the existing one). Blocks with no special informations in them are in the back layer of static blocks. Blocks with the 'islayer="true"' information in their '<position >' are rendered in the front layer of static blocks.

Example:

<position x="-17.175000" y="14.525000" islayer="true"/>

If you need even more granularity you can add a front layer with an x and y scroll of 1.0. This way the front layer will scroll at the same speed than the static blocks

Block properties

<block id="Block1">
	<physics grip="1.0"/>
	<position x="-0.333333" y="-5.666667" dynamic="true"/>
	<usetexture id="default"/>
	<vertex x="-7.666667" y="0.666667"/>
	<vertex x="7.333333" y="2.666667"/>
	<vertex x="0.333333" y="-3.333333"/>
</block>
all the properties are not mandatory. The default value will be given in this case.
  • id : identifier of the block ; allows you to change the block via a script
  • position : initial position of the block
  • dynamic : allow this block to move via a script if set to true
  • grip : grippyness of the block ; allows you to simulate ice [requires xmoto >= 0.2.1]
  • usetexture : texture applied on the block

Sprites properties

<entity id="Strawberry2" typeid="Strawberry">
 <size r="0.2" width="0.5" height="0.5"/>
 <position x="42" y="0.5" angle="3.14159" reversed="true"/>
</entity>
all the properties are not mandatory. The default value will be given in this case.
  • id : identifiant of the sprite ; allow to change the block via a script
  • typeid : type of the sprite
  • r : radius of the collision circle
  • width : width of the picture [require xmoto >= 0.2.1]
  • height : height of the picture [require xmoto >= 0.2.1]
  • x : position x of the center
  • y : position y of the center
  • angle : angle to draw the sprite [require xmoto >= 0.2.5]
  • reversed : mirror the picture [require xmoto >= 0.2.5]

This page was last modified on 26 November 2010, at 11:20. This page has been accessed 12,395 times.

  

Copyright © 2006