Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Question about Random Animation

    General and Desktop
    4
    5
    3261
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kale Lou last edited by

      Hi everyone,

      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.

      1 Reply Last reply Reply Quote 0
      • F
        Franzk last edited by

        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.

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply Reply Quote 0
        • B
          brandont last edited by

          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
          @

          1 Reply Last reply Reply Quote 0
          • F
            Franzk last edited by

            Teleporting is a basic feature of cars, right?

            "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply Reply Quote 0
            • T
              tobias.hunger last edited by

              Franzk: This might be a research project on teleporting cars, you never know. It is amazing where Qt is used nowadays:-)

              1 Reply Last reply Reply Quote 0
              • First post
                Last post