Difference between revisions of "Effect file"

From Serious Sam's Bogus Detour
Jump to: navigation, search
Line 17: Line 17:
  
 
===Expression language===
 
===Expression language===
 +
This is a simple language for creating dynamic values that can change over time for the effect components, for example if you want a sprite to fade out during the effect you might do something like
 +
    color-a="1 - t"
 +
or if you want it to pulse during the effect you could do
 +
    color-a="sin(t) / 2 + 0.5"
 +
 
====Parameters====
 
====Parameters====
 
There are four built in parameters for effects,
 
There are four built in parameters for effects,

Revision as of 22:04, 17 April 2017

.effect


File format

Sprite

Light

Trail

Param

These are values that can be sent to the effect and used in the effect expressions, for example these are used to send in an angle to most projectiles and rotate their sprites accordingly.

   <param name="angle" default="0" />

Variation

Data

Expression language

This is a simple language for creating dynamic values that can change over time for the effect components, for example if you want a sprite to fade out during the effect you might do something like

   color-a="1 - t"

or if you want it to pulse during the effect you could do

   color-a="sin(t) / 2 + 0.5"

Parameters

There are four built in parameters for effects,

t time 0-1
l loop 0+
u unit Not 0
i index 0+

The time parameter says where in the effect "timeline" you are, so it goes from 0 to 1 over the length of the effect, if the effect is looping then when time hits 1 it will reset to 0 and loop will increase by 1. So an expression like,

   t + l

will simply start at 0 and go up forever until the effect is stopped.

The unit parameter simply contains the unit id for the unit that is currently playing the effect, this is fairly unique but can be reused for future effects getting played.

And the index parameter only exists inside a trail effect component and simply contains the id of the current segment in the trail.

More parameters can be added to an effect using the <param> tag and has to be filled with values by scripts.


Functions

sin Simple sine function, takes radians
cos Simple cosine function, takes radians
abs The absolute value, basically just turns negative values in to positive ones
ceil Rounds a value up to the next or current integer
floor Rounds a value down to the previous or current integer
exp Returns e raised to the specified power
log Returns the natural (base e) logarithm of a specified number
saturate Clamps a number to 0-1
sign The sign of the number (-1, 0 or 1)
sqrt Square root
clamp clamp(v, min, max) - Clamps v so it is not lower than min or higher than max
lerp lerp(t, a, b) - Linearly interpolates from a to b using t (0-1)
smoothstep smoothstep(t, a, b) - Smoothly interpolates from a to b using t (0-1)
min Returns the smallest of two values
max Returns the largest of two values
pow pow(a, b) - Returns a to the power of b
rand Returns a random value based on an input value, for example rand(t) returns a new value every frame while rand(l) returns a new value every time the effect loops
wposx wposx(n) - Returns the x coordinate of where this unit was n frames ago relative to their current position
wposy wposy(n) - Returns the y coordinate of where this unit was n frames ago relative to their current position