Lets say you have a text on the bottom left corner of your screen: D.text(-1.2,-1,"sdfsdsdf");
..but you want to make it more cool looking, more exciting. You feel like you want that text to move across the screen slowly, then fast, then out of site.
Since the first parameter of D.text is the x location of the text, and since it's a constant, it won't do what you want it to do.
To tackle this is to make a simple function. Lets call this function calcx. Since the first parameter of D.text takes in a Flt, this function would also have to return the same type, type Flt. So, lets declare it and also a variable for x.
Code:
Flt x = -1.3; //initial starting position of x
Flt calcx()
{
if(pressed>3)//pause for 3 seconds, then animate.
{
x=x*-x);//changes x position
}
if(x>=1.3)
{
stopdrawing();//x posistion is offscreen. stop drawing
}
return x;
}
Okay,the function is done, time to use it: D.text(calcx(),-1,"sdfsdsdf");
Now it moves, cool.