Created
June 26, 2020 20:51
-
-
Save shorinji/4e37a1cb1ec049a4cd4486dafb9fa30e to your computer and use it in GitHub Desktop.
example snippet of building up filenames and loading images dynamically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
walkRightImageCodes = ['A1', 'A2', 'A7', 'Fb9', 'Bx5'] | |
walkRightImageData = [] | |
# easy to read version | |
for code in walkRightImageCodes: | |
filename = "%s.png" % code | |
imageData = pygame.image.load(filename).convert() | |
walkRightImageData.append(imageData) | |
# short version | |
walkRightImageData = [ pygame.image.load("%s.png" % code).convert() for code in imageCodes ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment