On Jun 10, 6:50 pm, dasacc22 <[email protected]> wrote:
> > I've tested the game but the bullets aren't getting deleted, they
> > linger through all the scenes.
>
> yeah i wasn't going for being super fix-it, just finding and fixing
> your problem so you can figure out how you want it fixed.
>
> > Also, I seem to be missing the point of
> > "bullets = []".
>
> the way you were using the global bullets list was confusing to me.
> Basically i couldn't tell if you were declaring the global first
> somewhere. Heres an example, you can pull up a python interpretor
>
> class A(object):
>     global s
>
>     def greet(self):
>         print s
>
>     def reset(self):
>         s = 'reset'
>
> >>> a = A()
> >>> a.greet()
>
> Name Error: global name 's' not defined
> ' ok so now lets set it in globals '>>> s = 'Bonjour Mary!'
> >>> a.greet()
>
> Bonjour Mary!
> ' ok so lets see if our reset function works '>>> a.reset()
> >>> a.greet()
>
> Bonjour Mary!
>
> Nope, this is b/c theirs some weird clashing going on that i dont
> fully understand. It can be alleviated by declaring global s in every
> function like so
> class A(object):
>     def greet(self):
>         global s
>         print s
>     def reset(self):
>         global s
>         s = 'reset'
>
> which i think is kind of ugly, or you can declare an object in your
> Bullet module that you import everywhere. In your bullet module,
> anything you initialize in their will be accessible to anything in
> your source module. Think of it like this. If you import math, well
> now anywhere in your code you can call math.degrees() or whatever. The
> same applies for when you import bullet. Now anywhere in your code you
> can access bullet.bullets list or whatever you want to initialize.
> When you import bullet across multiple files, they will all be working
> with the same list.
>
> So the only suggestions i have, you can either try to explicitly
> declare global bullets in each function you use it in or you can try
> what i suggested and make use of a bullet namespace.

I finally get what you mean. I managed the bullets list by declaring
it global everytime I used it, but I didn't do it very well.

Anyway, I fixed the problem. I was using the same bullet list, there
was nothing wrong with that. It turns out I was not clearing the
bullet list properly. As I mentioned in the earlier post, I cleared
the bullet list by popping it until it was empty and everything works
perfectly. It seems I need to familiarize myself more with Python
lists. Either way, I need to look through the whole code again and
optimize some implementations and any hard coding. Thank you
everyone :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to