[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Some more comments.




The last bug not always happens at some given iteration. If you play
randomly you get different results. I tested with HWSURFACE and it worked
much faster.

Maybe it is my code, but I'm not creating any new objects inside the
iteration, except for the events, but if you just hold one key until it
freezes only 2 or 3 may be created and that's not enough, I supose. The
program is fairly simple too.

An observation about the API:

Surface is not a high-level object - I have to disclaim that I'm not that
experienced in python. The problem is that I can't derivate a class from a
Surface, which is a shame. If you check the program I'm working on:

http://primates.ximian.com/~arturo/Junk/game.py

you'll see that I have a class named Scene. I tried to derivate from
pygame.Surface, but that was impossible: pygame.Surface is a function. :)

Then I printed a surface object in the interpreter and it seems to be a
built-in type, which I suppose maps directly to the C structure.

Now, one possibility would be to do something like pygtk:

class pySurface:
 def __init__ (self, w, h, obj = None):
  if not obj:
   obj = pygame.Surface ((w, h))
  self.__obj = obj

 def get_at (self, pos):
  return self.__obj.get_at (pos)

 def get_bitsize (self):
  return self.__obj.get_bitsize ()

 etc...

This allows to do stuff like:

class my100x100Surface (pySurface):
 def __init__ (self):
  pySurface.__init__ (self, 100, 100)

 blah blah.

Which adds some fexibility.

What about that? Maybe I can contribute with sth like that for this
weekend, for all the builtin structures you have. It wouldn't be
incompatible with the current API, and it's not that inefficient. You can
always refer to the object (the actual Structure or CD or whatever) if you
want as much efficiency as possible.

Greetings,
Arturo



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org