Jump to content
  • Advertisement

kingpinzs

Member
  • Content count

    1780
  • Joined

  • Last visited

Community Reputation

117 Neutral

About kingpinzs

  • Rank
    Contributor
  1. kingpinzs

    python collision recursion issue

    I changed bubbles.remove(bubble1)  to bubbles.discard(bubble1) and I no longer get the error. Thanks every one for taking the time to read my post.
  2. kingpinzs

    python collision recursion issue

    def remove_matching(self, bubbles): bubble_old = [] for bubble in list(bubbles): if self.color == bubble.color and self.collide(bubble): bubble_old = bubble bubbles.remove(bubble) self.touching(bubble_old, bubbles) return True return False this is the method that calls it.  The code works when the bubbles are lined up like this   x O x x O x x O x   O <-current ball      x  O  x x  O  x O O O    O <-current ball   the issue happens with anything like this   O O O O    O <-current ball   I have also tried this def touching(self, bubble, bubbles): for bubble1 in list(bubbles): if self.color == bubble1.color and dist(bubble.pos, bubble1.pos) <= 2 * BUBBLE_RADIUS: bubbles.remove(bubble_old) self.touching(bubble1, bubbles) I got the same error   and this gets this error RuntimeError: Set changed size during iteration  def touching(self, bubble, bubbles): for bubble1 in iter(bubbles): if self.color == bubble1.color and dist(bubble.pos, bubble1.pos) <= 2 * BUBBLE_RADIUS: bubbles.remove(bubble1) self.touching(bubble1, bubbles)
  3. def touching(self, bubble, bubbles): for bubble1 in bubbles: bubble_old = bubble1 if self.color == bubble_old.color and dist(bubble.pos, bubble_old.pos) <= 2 * BUBBLE_RADIUS: bubbles.remove(bubble_old) self.touching(bubble1, bubbles)     The error occurs when there are two rows right next to each that need to be removed. for example like this x x  x  x  x x O O O x x x  O O x x x  O  x x        O <-current ball Traceback (most recent call last):   File "main.py", line 140, in draw     if a_bubble.remove_matching(stuck_bubbles):   File "main.py", line 72, in remove_matching     self.touching(bubble_old, bubbles)   File "main.py", line 81, in touching     self.touching(bubble1, bubbles)   File "main.py", line 80, in touching     bubbles.remove(bubble_old) KeyError: <__main__.Bubble instance at 0x192c878>  
  4. kingpinzs

    How do I use a class object as a parameter?

    Thanks for the help that fixed my issues. all I did    class Monster; // fwd declaration
  5. kingpinzs

    How do I use a class object as a parameter?

    I am getting errors. error: 'Monster' does not name a type error: 'Monster' has not been declared
  6. How does one go about passing a class object as a parameter in another class's method.   e.g. class Player { Monster monster; bool attack(Monster& monster); }   class Monster { //do stuff   }    
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!