Question about Random Animation
I am trying to make a small software of mobile network performance simulation. For the display part, I wanna to have several vehicle icons move randomly in screen. Currently, my idea is based on the Animation Framework Examples, such as "Animated Tiles" and "Move Blocks". Basically, they use "QState" to predefine a set of geometry states and randomly pick one of them when the program run.
My question is how to make the geometry state random, so that you will see the car image randomly move in the screen, not just a set of patterns.
Anyone has any idea or any example code?
Thanks in advance.
This kind of depends on how many degrees of freedom you have. If there's two (e.g (x, y)) you can relatively easily parameterize it based on a random number. If there's three, you might want to be using more inputs.
Just another small point. The random integers should be 1 or -1 (multiply an integer for different speeds). Just add the number to the coordinates. Unless of course you want the cars to teleport around the screen. :P
You might not want your cars to turn on every step, so you might choose a prng that "tends" to stay constant. Maybe something like this:
a is the generated number
b is a private double
Increase b by a small random amount under 1 (say under 0.3).
If b is not over 1
return last a
if b is =< 1
return random a
Teleporting is a basic feature of cars, right?
Franzk: This might be a research project on teleporting cars, you never know. It is amazing where Qt is used nowadays:-)