omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Transformation matrix?

    Pythonista
    matrix transformation beta question
    2
    7
    5761
    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.
    • Sebastian
      Sebastian last edited by

      I'm having som problems with the new node system of the 1.6 beta. Is there an equivalent to the previous scene.translate function?

      1 Reply Last reply Reply Quote 1
      • JonB
        JonB last edited by

        Wouldn't you just use Node.position? Or Action.move_by?

        1 Reply Last reply Reply Quote 0
        • Sebastian
          Sebastian last edited by

          I managed what I was trying to do, by using a "world node" and a "player node", the player node is just centered on the screen, while the world is the node that is actually being moved around. Now my collision detection fails, so I guess I have to use Node.point_to_scene or Node.point_from_scene, but I haven't figured out how they work.

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            See the new examples, such as BrickBreaker.py for ideas.
            I think you want to use rect.intersects(bbox)

            1 Reply Last reply Reply Quote 0
            • Sebastian
              Sebastian last edited by

              I'll try to explain it a bit further.
              The objects that need collision detections are circles, so I checked if the cartesian distance between the two circles were less than the player circle's radius. I used a scene.ShapeNode as the world, that moves around the player, and that contains the other circles as child nodes. This makes the coordinates of the objects inside the world different from those in the scene.Scene. So I think I need some way to get the coordinates relative to the screen.

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                So, you could use point to scene on the circle center first. But, if all of your collision objects are direct subnodes of the world node:

                 scene
                 |
                 +-- player
                 |
                 +-- world node
                         |
                         +-- ball1
                         +-- ball2
                         +-- etc
                

                you could basically just add the world position to the ball,positions:

                hit_test(player.bbox, world.ball1.bbox.translate(world.x,world.y))
                

                Look at BrickBreaker's hit_test()... it does a quick interescts, followed by checking the distance. You could do something similar, except that for circle to circle collission you simply compute the distance between circle centers (you can just subtract the bbox.centers, which produces a Vector2, and you can use abs to get length of the vector efficiently) and check if it is greater than the sum of radii.

                1 Reply Last reply Reply Quote 0
                • Sebastian
                  Sebastian last edited by

                  I think that's exactly what I'm looking for! Thanks @JonB :)

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors