1. Marcus von Appen
  2. py-sdl2
  3. Issues
Issue #41 wontfix

How to do Sprite Clipping?

cmpete
created an issue

I'm trying to use PySDL2 to implement a basic tile/sprite clipping system to render sprites clipped from a tilemap, like in this SDL2 tutorial.

sdl2.ext.RenderContext.copy() would probably do what I want, but I'm trying to modify the pong example or in other words using a spritefactory and can't seem to be able to create a RenderContext properly to let me clip a part of a larger sprite (tilemap) into a new sprite to assign to a player entity to be drawn by the RenderSystem.

What am I doing wrong, and what's the best/most Pythonic/most pysdlish way to do this?

Comments (5)

  1. cmpete reporter

    I ended up creating a custom TileRenderSystem class and using sdl2 directly and almost no sdl2.ext helper classes. Basically, it uses a Texture Renderer which instead of rendering sprites, it renders clips from a tileMap based on a tile index.

  2. Marcus von Appen repo owner

    Clipping would be done with RenderContext.copy(). The TextureSpriteRendererand SoftwareSpriteRenderer assume each sprite to be rendered to be completely visible without displacing parts via clipping.

    So, your approach might be a good way to do things, since the provided sdl2.ext classes do not provide that functionality.

  3. Log in to comment