EnigmaSand3 Physics File
From FSG Wiki
←Older revision | Newer revision→
XML Physics File
Elements and reactions can be customized in EnigmaSand by using the default.xml file found in the home directory of the game. All physics files have to start with <enigmasand> and end with </enigmasand> in order for the parser to read it. The rest of the code is build up with element tags that define the different types of elements that can be used in the game. Below is an example of such a tag.
- If you're not familiar with the XML markup language, please read this page first.
<element name="ALCOHOL" color="FFAADDFF" dens="0.79" menu="1"> <gravity g="0.95" r="0.25"/> <self chance="0.01" result="BLANK"/> <reaction chance="0.3" trigger="WATER" res1="1.0" ares1="BLANK" bres1="SOLUTION"/> <explosion chance="0.3" trigger="FIRE" type="1" sizex="0.5" result="FIRE"/> </element>
This example element contains all tags and parameters supported by the game, each will now be explained by using small examples that are easier to understand.
<element name="STEEL" color="FFAAAAAA" dens="7.85" menu="1"/>
This piece of code creates an element named 'STEEL'. The color of this element will be grey as is specified by the hex code #AAAAAA. In front of this hex code EnigmaSand uses two digits to specify the alpha channel(not supported yet, always FF). The "dens" parameter specifies the density of the material in kilograms/liter. Lastly there's a "menu" parameter that defines wether or not the element is shown in the game, if the value is "0" or "NO" it will not be shown in the list. The element will be shown by default if the menu parameter is not set.
<element name="SAND" color="FFEECC80" dens="1.4"> <gravity g="0.95" r="0.25"/> </element>
The way particles behave is defined using the gravity tag. This tag has two parameters, "g" defines the speed at which the particles fall(acceleration), this value is usually between -1 and 1, with a negative value resulting in the particles behaving like a gas. The "r" parameter defines the rate of slip, a lower value will result in the particles falling closely to eachother and forming a pile when they land, a higher value will make the particles spread out and easily slide of eachother. If you do not include the gravity tag the particles will ignore gravity and stay in the same place as you put them.
<element name="ICE" color="FFBBEEFF" dens="0.01"> <self chance="0.001" result="WATER"/> </element>
The self tag is used to make an element turn into another element after a certain time. The chance parameter specifies how long it takes for this to happen, a value of 1 means that the event will happen once everytime a frame is rendered, a value of 0.1 means the event will take place on every thousandth frame. The result parameter specifies what element it should be changed into, in this case the element changes into BLANK, thus dissapearing.
<element name="SODIUM" color="FFEEEEEE"> <reaction chance="0.1" trigger="WATER" res1="0.5" ares1="SODIUM" bres1="FIRE" res2="0.5" ares2="BLANK" bres2="FIRE"/> </element>
Elements can react with other elements by using the reaction tag. This tag is comparable to the self tag in that it changes the element it's contained in into something else, the difference is that there has to be a trigger touching the element particle for this to happen. The chance parameter is exactly the same as in the self tag, it defines how many times the reaction should occur each time a frame is rendered. The trigger parameter specifies which element should be touching the particle for the reaction to happen. res1 is the chance of result 1 occurring, ares1 defines what element the reactant(the element containing the reaction code) should change to and bres1 defines what element the trigger should turn into. You can have as many results as you want by simply incrementing the number following the res, ares and bres tags. In the above example the sodium will react with water at a rate of once every ten frames resulting the water turning into fire and the sodium dissapearing in 50% of the reactions.
<element name="BOMB" color="FFAA2222" dens="0.9"> <explosion chance="0.3" trigger="FIRE" type="0" sizex="1.3" result="FIRE"/> </element>
This last piece of code creates a bomb that will explode when you light it. This tag is pretty much the same as the reaction tag and also contains the chance, trigger and result parameters. The only different parameters are type and sizex. Currently there are two types of explosions in the game, with 0 being a flash like explosion and 1 a particle explosion. The sizex parameter is a multiplier which specifies the size of the explosion, 1 is the default size.
