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.


    Scene Questions

    Pythonista
    3
    11
    4132
    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.
    • AtomBombed
      AtomBombed last edited by

      Does anyone have an idea of how to make sprite collision detection using bbox or something like that to detect it? I have a sort of an idea, but I want to hear other peoples' first.

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

        "What are those"? Really?

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

          @Webmaster4o What?

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

            Read through the scene docs, it specifically covers hit testing.

            For hit-testing purposes, you can check if a Point lies within a Rect using the in operator. To check if one rectangle intersects with another, you can use the Rect.intersects() method (or Rect.intersection() if you need to know exactly where the rectangles intersect).

            for enemy in enemies:
               if enemy.bbox.intersects(player.bbox):
                   game_over()
            

            For different examples, such a circle intersecting a rectangle, see the Brick game in the Examples folder, and search for hit or collision (sorry I don't have it in front of me).. If you want to check just a point you would use in

            if bullet in player.bbox:
               game_over
            
            1 Reply Last reply Reply Quote 0
            • AtomBombed
              AtomBombed last edited by

              @JonB thank you so much. I read some, but I didn't get to that part.

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

                @JonB for a different question, how would I animate a Vector2 in the scene module. That one I have been trying a ton. I used the animate() function, the run_action() function, none work with a Vector2.

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

                  animate a vector? A vector2 is not something you draw.......what do you mean?

                  I would suggest looking at the Examples/Game Tutorial, and actually work through the exercises one by one. this will show you how to animate sprites, do collision detection, etc.

                  1 Reply Last reply Reply Quote 0
                  • Webmaster4o
                    Webmaster4o @AtomBombed last edited by

                    @AtomBombed The QR code in your profile picture.

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

                      @JonB well I just asked because I used to make games with Lua, and it had an animation function for animating Vector2 (vec2 in Lua), and so I was just wondering.

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

                        Are you trying to animate the position of some object (which is described by a Vector2?), that is, have something move from one point to another in a straight line in a smooth way over time? Or are you trying to draw a Vector2 (a line with an arrowhead starting from the origin?) and have it move. Use more words to describe what you are trying to do.... maybe without using the words vector or animate:)

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

                          @JonB thanks for your willingness to help, but I just went about another way of doing it. Instead of having a sepereate table of each of the generated random positions for each asteroid and setting the asteroid sprite at those positions using a for loop, I just deleted that whole list worth the positions, and decided to use a list that already had the sprite objects in it making it way easier than my previous approach. I have no idea why I didn't try this first.

                          Really appreciate it, though.

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