Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


kingpinzs

Member Since 23 Aug 2002
Offline Last Active May 28 2014 10:21 AM

Posts I've Made

In Topic: python collision recursion issue

18 May 2014 - 07:22 PM

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.


In Topic: python collision recursion issue

18 May 2014 - 09:02 AM


    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)

In Topic: How do I use a class object as a parameter?

02 June 2013 - 11:51 PM

Thanks for the help that fixed my issues.

all I did 

 

class Monster; // fwd declaration


In Topic: How do I use a class object as a parameter?

02 June 2013 - 11:28 PM

I am getting errors.

error: 'Monster' does not name a type
error: 'Monster' has not been declared

In Topic: Need help with a array sequence

12 February 2012 - 10:39 PM

After thinking about it for a while I came up with this.




void sequence::advance( )
{

if(is_item())
{

if(current_index <= used-1)
{
++current_index;
}

}
}

but it is still advancing passed the array that has been created.

PARTNERS