I'm trying to learn how to code some "effects" more succinctly.
For example, I have sprite clouds in my game, and their transparency is determined with the following formula on their update-method, which is called repeatedly.
float transp = Math.abs(MathUtils.sin(0.2f * time) * 0.4f);
This works OK. However, let's say, that when the transparency reaches < 0.2, I want it to stay there, for some time, and so that the duration is randomized.
I could of course hack this with some "ugly" variables or something, but like I said, I'm trying to learn how to do stuff like this more to the point, hopefully with one-or-few-liners. In other words, more elegantly, more mathematically. Maybe more functionally would be the right description.
Perhaps some demoscene code could be a good starting point for learning things like this.
Anyone have any code or good examples or references to articles of such "dirty math tricks" (or this particular case)?