Pygame - Blitting From X And Y Cordinates Of Image
I'm trying to lessen the number of files I need for my pygame project by instead of having a folder with for example 8 boots files, I can make 1 bigger image that has all of them 8
Solution 1:
You can define a subsurface that is directly linked to the source surface with the method subsurface
:
subsurface(Rect) -> Surface
Returns a new Surface that shares its pixels with its new parent. The new Surface is considered a child of the original. Modifications to either Surface pixels will effect each other.
The Rect
argument of subsurface
specifies the rectangular area for the sub-image. It can either be a pygame.Rect
object or a tuple with 4 components (x, y, width, height).
For example, if you have an image that contains 3 100x100 size sub-images:
right_surf = pygame.image.load("playerdesigns/playerright.png")
right_surf_list = [right_surf.subsurface((i*100, 0, 100, 100)) for i inrange(3)]
Post a Comment for "Pygame - Blitting From X And Y Cordinates Of Image"