Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Collision detection code written(help needed)
Forum Updated to NodeBB v4.3 + New Features

Collision detection code written(help needed)

Scheduled Pinned Locked Moved QML and Qt Quick
15 Posts 6 Posters 7.4k Views 1 Watching
  • 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.
  • I Offline
    I Offline
    imrrk
    wrote on last edited by
    #4

    kxyu..how to do that

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kxyu
      wrote on last edited by
      #5

      put @ on the left and on the right of your code

      1 Reply Last reply
      0
      • I Offline
        I Offline
        imrrk
        wrote on last edited by
        #6

        hey kxyu,

        now the code is in readable format..so please help me out..with the code..

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #7

          I took the time to properly mark up your code, but I still do not get what do you want us to do for you. Are we supposed to fix it? It would be helpful to know what you want it to do.

          Here are a couple fo things I noticed while marking up your code: I am not a Javascript expert, but your collision detection code does not return anything, does it? The condition of that method seems to be totally broken, too... Why do you rotate by -360 degrees? Isen't that the same as no rotation? Is collisiondetection actually used anywhere?

          1 Reply Last reply
          0
          • I Offline
            I Offline
            imrrk
            wrote on last edited by
            #8

            hi tobias,,,i am also new to qml and javascript...i want to do collision detection to happen when the two images or rectangles or circles collide with each other...ya thats true that it does not return anything..because i am stuck in between..so i would be thankful to u if u help me out..

            Regards
            imrrk

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #9

              Did you really read what others told you in the other thread you created:

              "collision detection using qt quick":http://developer.qt.nokia.com/forums/viewthread/2912

              No answer from yours there! QtK

              Did you start a search on "collision detection" or use the tag search on "colission detection":http://developer.qt.nokia.com/search/tag/collision+detection?

              e.g. read this:
              "Regarding QML":http://developer.qt.nokia.com/forums/viewthread/1695

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

              1 Reply Last reply
              0
              • I Offline
                I Offline
                imrrk
                wrote on last edited by
                #10

                hello volver....
                i have checked ..it ,but its not concrete..solution....so i started this thread...can you provide me some fundamentals about this collision detection abt two bodies and also the bodies should respond to the collision..now i have managed to detect collision and the bodies are responding..but not in a proper flow....so if you would help me out..i will be very thanful to you...

                regards
                imrrk

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #11

                  No one can know that if you don't tell us!

                  Regarding the collision detection, I'm not into that field. You'll have to wait for someome else to jump in. Did you ask google for some general algorithms? It should not be too hard, to implement it in QML/JavaScript.

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

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    imrrk
                    wrote on last edited by
                    #12

                    thanks volker,I will try it out.........

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Kxyu
                      wrote on last edited by
                      #13

                      [quote author="imrrk" date="1294241393"]
                      can you provide me some fundamentals about this collision detection abt two bodies and also the bodies should respond to the collision.[/quote]

                      this "fundamentals" are called Physics, so you'd better start with a couple of books on mechanics.

                      or just download Box2D qml plugin. it's kind of unfinished, and as far as I know only contains box object implementation, but you can look how it's done and implement other shapes yourself, it's not that complex

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        krishkn
                        wrote on last edited by
                        #14

                        There are some ways to detect collision say for example to detect two rectangles getting collided

                        function isColiding (x1, y1, width1, height1,x2, y2, width2, height2) {
                        return (x1 < x2 + width2) && (y1 < y2 + height2) &&
                        (x1 + width1 > x2) && (y1 + height1 > y2);
                        }

                        :)

                        Regards,
                        Krishkn

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mbrasser
                          wrote on last edited by
                          #15

                          Hi,

                          In the case of the example, one thing missing is that the collisiondetection function is not being called anywhere. A simple modification of the code might be to add a Timer object that calls this function every animation tick, something like:
                          @
                          Timer {
                          repeat: true
                          running: true
                          interval: 16
                          onTriggered: collisiondetection()
                          }
                          @
                          Regards,
                          Michael

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved