Skip to content

Instantly share code, notes, and snippets.

@cbscribe
Created January 24, 2017 04:41
Show Gist options
  • Save cbscribe/3d9fe81459aa86d0374ff626f2d25c87 to your computer and use it in GitHub Desktop.
Save cbscribe/3d9fe81459aa86d0374ff626f2d25c87 to your computer and use it in GitHub Desktop.
basic spritesheet class
class Spritesheet:
# utility class for loading and cutting spritesheets
def __init__(self, filename):
self.spritesheet = pg.image.load(filename).convert_alpha()
def get_image_by_rect(self, x, y, w, h):
r = pg.Rect(x, y, w, h)
return self.spritesheet.subsurface(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment