pgzero icon indicating copy to clipboard operation
pgzero copied to clipboard

Better support for creating your own surfaces

Open lordmauve opened this issue 7 years ago • 3 comments

In lordmauve/snowgame we encountered several places where we needed to bypass Pygame Zero's APIs in order to create new surfaces, blit actors to them, and set pixels.

In some ways it was always intended that you could directly access Pygame, but I was surprised at how little Pygame Zero functionality could be used once you do.

For example, it would be useful if Actors could take a surface that they were attached to as a parameter, and optionally have it overridden in Actor.draw().

It would be useful to wrap new "Screen" objects around newly created surfaces.

It would be useful to be able to create a "Screen buffer" by copying the dimensions of a screen.

lordmauve avatar Mar 02 '18 09:03 lordmauve

If this is done, it could also add support for Pygame subsurfaces, which would make #43 Sprite sheets easier. In the game I'm making, I use a (non-animated) tileset and subsurfaces to draw the environment. I can work on this, if you want.

sapoturge avatar Jun 25 '19 02:06 sapoturge

That would be great. I don't have strong views on how this would work. I'd love to see ideas!

lordmauve avatar Jul 17 '19 22:07 lordmauve

Have such capabilities -- especially, associating new surfaces with Actors -- since evolved? Specifically, I'd really like to use Pillow to synthesize surfaces, which then can be animated with Actor capabilities. I've been trying to inject these with _surface_cache appends (after b = img.tobytes("raw", "RGBA"); s=pygame.image.fromstring(b, img.size, "RGBA");), but the guards around the private variable seem to be obstructing. Do any have ideas how to go about this? Warmly appreciated!

ullmer avatar May 28 '22 04:05 ullmer